1

I have an entry which has a category field 'productCategory' and the chosen category is a nested one (3 deep), I want to output the category and where it's nested, but by using the field's name: {{ entry.productCategory.one() }} I get the parent category only, because of .one() I guess, if I use without .one(), then I get a tonne of queries displayed, so I'm not sure how to even approach displaying the actual nested category like a breadcrumb trail. I can display the categories as a nested navigation, but for now I want the entry's chosen category, any ideas? Thanks

1

aah

{% for category in entry.productCategory %}
    {{ category.title }} >
{% endfor %}
| improve this answer | |
  • now to highlight the nested category! – user2569 Oct 16 '19 at 17:00
  • Is there a way to make a nested category active? – user2569 Oct 17 '19 at 11:15
  • the entry category field value is: Transformers > Standard Fixed Installation Transformers > Wall/floor mounting Transformers 1-10KVA – user2569 Oct 17 '19 at 11:15
  • I want make 'Wall/floor mounting Transformers 1-10KVA' active – user2569 Oct 17 '19 at 11:17
  • so I need a way to dynamically detect what level the nested category is: rather than this static approach: <ul> {% nav category in entry.productCategory %} <li> {% if category.level == 1 %} {{ category.title }} </li> {% endif %} {% if category.level == 2 %} {{ category.title }} {% endif %} {% if category.level == 3 %} <a href="{{ category.url }}">{{ category.title }}</a> {% endif %} {% endnav %} </ul> – user2569 Oct 17 '19 at 11:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.