<p>I don't think I quite follow you, so forgive me if I'm way off. I have created (what I think) is something similar to what you are looking for. This is how I did it - maybe it will help...</p>

<p>Let's say I have the following url:</p>

<pre><code>http://www.mystore.com/toys/my-awesome-toy
</code></pre>

<p><strong>twig</strong></p>

<pre><code>{% set cat = craft.categories.slug(craft.request.getSegment(2)).first() %} {# Toys #}

{% for toys in craft.categories.group('toys').descendantOf(cat).level(2) %}
    {% if toys.getDescendants().total() != 0 %}
        {% for subToys in craft.categories.group('toys').descendantOf(toys.id).level(3) %}
            ...
        {% endfor %}
    {% endif %}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2015-11-18T16:59:39.407Z
cheers that's got me on the right track
Lettie
CC BY-SA 3.0
2015-11-18T19:30:13.780Z
Awesome - glad it helped!. Can you update your post to show what you ended up with?
Damon
CC BY-SA 3.0
2015-11-18T15:24:04.453Z
2015-11-18T15:24:04.453Z
Damon
<p>I'm looking to use multiple category group as a navigation. The categories have 3 levels and will be listed depending on set variable. I can list all categories in the group with the following:</p>

<pre><code>{% set categories = craft.categories.group('categories') %}
&lt;ul&gt;
    {% nav category in categories %}
        &lt;li&gt;
            &lt;a href="{{ category.slug }}"&gt;{{ category.title }}&lt;/a&gt;
            {% ifchildren %}
                &lt;ul&gt;{% children %}&lt;/ul&gt;
            {% endifchildren %}     
        &lt;/li&gt;
    {% endnav %}
&lt;/ul&gt;
</code></pre>

<p>However I would like to list only the third level categories after the top level and secondary level have been set. I've tried playing around with descendantOf but to no avail. Any help to point me in the right direction much appreciated.</p>

<p>---Final code----
After @damon input below this is what I ended up with more or less the same:</p>

<pre><code>{# ---- Set Default Segment ---- #}
{% set segment = 'default' %}
{# ---- If url segment is set, set segment to it ---- #}
{% if craft.request.getSegment(2) %}
    {% set segment = craft.request.getSegment(2) %}
{% endif %}
{% set cat = craft.categories.group('categories').slug(segment).first() %}
{% for categories in craft.categories.group('categories').descendantOf(cat).level(2) %}
    {% if categories.getDescendants().total() != 0 %}
        {% for category in craft.categories.group('categories').descendantOf(categories.id).level(3) %}
            ...
        {% endfor %}
    {% endif %}
{% endfor %}
</code></pre>

<categories><category>
Dealing with listing multiple categories
# Dealing with listing multiple categories

(Asked by: username_0 on 2015-11-18)

I'm looking to use multiple category group as a navigation. The categories have 3 levels and will be listed depending on set variable. I can list all categories in the group with the following:
{% set categories = craft.categories.group('categories') %}

    {% nav category in categories %}
        
            {{ category.title }}
            {% ifchildren %}
                {% children %}
            {% endifchildren %}     
        
    {% endnav %}


However I would like to list only the third level categories after the top level and secondary level have been set. I've tried playing around with descendantOf but to no avail. Any help to point me in the right direction much appreciated.
---Final code----
After @damon input below this is what I ended up with more or less the same:
{# ---- Set Default Segment ---- #}
{% set segment = 'default' %}
{# ---- If url segment is set, set segment to it ---- #}
{% if craft.request.getSegment(2) %}
    {% set segment = craft.request.getSegment(2) %}
{% endif %}
{% set cat = craft.categories.group('categories').slug(segment).first() %}
{% for categories in craft.categories.group('categories').descendantOf(cat).level(2) %}
    {% if categories.getDescendants().total() != 0 %}
        {% for category in craft.categories.group('categories').descendantOf(categories.id).level(3) %}
            ...
        {% endfor %}
    {% endif %}
{% endfor %}

**Tags:** categories, category

---

## 1 answers

### Answer by username_1 on 2015-11-18. Score: 2 | Accepted answer

I don't think I quite follow you, so forgive me if I'm way off. I have created (what I think) is something similar to what you are looking for. This is how I did it - maybe it will help...
Let's say I have the following url:
http://www.mystore.com/toys/my-awesome-toy

twig
{% set cat = craft.categories.slug(craft.request.getSegment(2)).first() %} {# Toys #}

{% for toys in craft.categories.group('toys').descendantOf(cat).level(2) %}
    {% if toys.getDescendants().total() != 0 %}
        {% for subToys in craft.categories.group('toys').descendantOf(toys.id).level(3) %}
            ...
        {% endfor %}
    {% endif %}
{% endfor %}

> **Comments:**
> **username_0**: cheers that's got me on the right track  
> **username_1**: Awesome - glad it helped!. Can you update your post to show what you ended up with?  

---

