如何删除空类别?

发布于 01-13 19:06 字数 440 浏览 5 评论 0 原文

我有两个场景需要解决:)

  1. 假设我构建了插件(使用构建器),其中有产品和类别。 现在在列出类别的页面上我拥有所有类别,但我不想显示空类别。 如何删除列表中的空类别?

  2. 第二个场景。有些产品有选项,有些则没有。 产品和选项有关系表。 在单个产品页面上我有一些类似的内容:

产品描述 该产品的选项 (效果很好)

但如果产品没有任何我想要的选项:

产品描述 文本“此产品没有选项”(或根本不显示任何文本)

到目前为止,我已经尝试过类似的操作:

{{ if option in record.options == true }} 显示选项 {{ 别的 }} “该产品没有选项” {{ endif }}

但这根本不起作用。

有没有办法检查产品的现有选项?

感谢您抽出时间。

I have a two scenarios to solve :)

  1. Let's say I built plugin (with builder) where I have products and categories.
    Now on page with listed categories I have all of them, but I want to not display empty categories.
    How to remove empty categories form listing?

  2. Second scenario. Some of products have options and some none.
    Products and options have relation table.
    On single product page I have some like:

product description
options for this product
(that work well)

But in case of product doesn't have any options I want to have:

product description
text "this product have no options" (or not display any text at all)

So far I have tried something like:

{{ if option in record.options == true }}
display options
{{ else }}
"this product have no options"
{{ endif }}

But this doesn't work at all.

Is there a way to check for existing options for product?

Thanks for your time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文