<p>aah</p>

<pre><code>{% for category in entry.productCategory %}
    {{ category.title }} &gt;
{% endfor %}
</code></pre>

CC BY-SA 4.0
2019-10-16T17:00:38.357Z
now to highlight the nested category!
user2569
CC BY-SA 4.0
2019-10-17T11:15:02.173Z
Is there a way to make a nested category active?
user2569
CC BY-SA 4.0
2019-10-17T11:15:44.257Z
the entry category field value is:

Transformers  
> Standard Fixed Installation Transformers  
> Wall/floor mounting Transformers 1-10KVA
user2569
CC BY-SA 4.0
2019-10-17T11:17:34.080Z
I want make 'Wall/floor mounting Transformers 1-10KVA' active
user2569
CC BY-SA 4.0
2019-10-17T11:42:32.387Z
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
CC BY-SA 4.0
2019-10-16T16:59:08.313Z
2019-10-16T16:59:08.313Z
user2569
<p>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: <code>{{ entry.productCategory.one() }}</code> I get the parent category only, because of <code>.one()</code> I guess, if I use without <code>.one()</code>, 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</p>

<category>
Display nested category
# Display nested category

(Asked by: username_0 on 2019-10-16)

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

**Tags:** category

---

## 1 answers

### Answer by username_0 on 2019-10-16. Score: 1

aah
{% for category in entry.productCategory %}
    {{ category.title }} >
{% endfor %}

> **Comments:**
> **username_0**: now to highlight the nested category!  
> **username_0**: Is there a way to make a nested category active?  
> **username_0**: the entry category field value is:  Transformers   > Standard Fixed Installation Transformers   > Wall/floor mounting Transformers 1-10KVA  
> **username_0**: I want make 'Wall/floor mounting Transformers 1-10KVA' active  
> **username_0**: 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>```  

---

