如何解决如何查看产品类型的机器名称?
我有下面的 TWIG 代码可以使用。它检查“产品”是否在产品类型的名称中。
我的问题:
我希望它检查产品类型的机器名称(不是机器名称的标题),在我的例子中是 product
你是怎么做到的?
{% if 'Produit' in message.field_product_reference.entity.field_pop_up_product_reference.entity.type.entity.label %}
<a href="{{ path('entity.commerce_product.canonical',{'commerce_product': message.field_product_reference.entity.field_pop_up_product_reference.entity.id}) }}" title="{{ message.field_product_reference.entity.field_pop_up_product_reference.entity.title.value }}" class="stretched-link"></a>
{% else %}
<a href="{{ path('entity.commerce_product.canonical',{'commerce_product': message.field_product_reference.entity.id}) }}" title="{{ message.field_product_reference.entity.title.value }}" class="stretched-link"></a>
{% endif %}
解决方法
试试 entity.bundle
而不是 label
: )
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。