如何获取分类法的当前选项名称?
How do I get taxonomy's current option name?
我有一个 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”这样的 url 时如何获得当前选项(在本例中为照明)?
我在 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 %}
我有一个 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”这样的 url 时如何获得当前选项(在本例中为照明)?
我在 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 %}