我有一个taxonomy.yml文件:
categories:
name: Categories
slug: categories
singular_name: Category
singular_slug: category
behaves_like: categories
multiple: true
options: [ Lighting, Stools, BarCart, Desk, SideBoard, BookShelf, Chairs, AccentChairs, Side Table, Media Unit, Console ]
listing_template: products.twig
现在在products.twig
模板中,当我在“/ meubles_bolt / categories / lighting”这样的网址上时,如何获取当前选项(在这种情况下点亮)?
答案 0 :(得分:1)
我在listing.twig
模板中使用以下内容来显示类别标题:
{% if taxonomytype is defined %}
<h1 class="listing">
{{ __('Overview for') }}
{% if taxonomy.options[slug] is defined %}
{{ taxonomy.options[slug]|capitalize }}
{% else %}
{{ slug|capitalize }}
{% endif %}
</h1>
{% endif %}