<p>Turns out I was overthinking it, I was able to connect it with the following piece of code.</p>

<pre><code>{% set levelOne = category.topLevelConnection %}
{% for subCat in craft.categories.group('levelTwo').relatedTo(levelOne) %}
</code></pre>

CC BY-SA 3.0
2016-05-06T10:18:05.653Z
2016-05-06T10:18:05.653Z
conormcafee
<p>I've been trying to get this working but can't seem to find a solution.</p>

<p>I have two different types of Categories in a commerce project.</p>

<ul>
<li>Level One</li>
<li>Level Two</li>
</ul>

<p>Examples</p>

<ul>
<li>Level One would be Mens, Ladies, Kids etc</li>
<li>Level Two would be T-Shirts, Jumpers, Shoes etc</li>
</ul>

<p>When I click on 'Mens' on the navigation, it brings me to the Mens page, I then get a sub navigation on that page which shows me any Level Two categories that are related to the Level One category (Mens).</p>

<p>These are related by using the categories field type.</p>

<p>This is got easily by the following:</p>

<pre><code>{% for subCat in craft.categories.group('levelTwo').relatedTo(category) %}
</code></pre>

<p>The problem that I encounter now, is when you click on one of the Level Two categories on that sub nav (T-Shirts for example), it brings me to the t-shirt category page.  I want to be able to display the same sub nav that is on Level One (Mens), on the Level Two (T-shirts) page.</p>

<pre><code>{% for subCat in craft.categories.group('levelTwo') %}
</code></pre>

<p>The above snippet shows me all the categories in Level Two, which is wrong.  </p>

<p>I need to be able to show all the categories in Level Two, that have have the same categories field type.  The handle of this categories field type is topLevelConnection.</p>

<p>Any suggestions would be greatly appreciated! </p>

<categories><relations><category>
Relating a Category Entry to a Categories Field Type
# Relating a Category Entry to a Categories Field Type

(Asked by: username_0 on 2016-05-06)

I've been trying to get this working but can't seem to find a solution.
I have two different types of Categories in a commerce project.

Level One
Level Two

Examples

Level One would be Mens, Ladies, Kids etc
Level Two would be T-Shirts, Jumpers, Shoes etc

When I click on 'Mens' on the navigation, it brings me to the Mens page, I then get a sub navigation on that page which shows me any Level Two categories that are related to the Level One category (Mens).
These are related by using the categories field type.
This is got easily by the following:
{% for subCat in craft.categories.group('levelTwo').relatedTo(category) %}

The problem that I encounter now, is when you click on one of the Level Two categories on that sub nav (T-Shirts for example), it brings me to the t-shirt category page.  I want to be able to display the same sub nav that is on Level One (Mens), on the Level Two (T-shirts) page.
{% for subCat in craft.categories.group('levelTwo') %}

The above snippet shows me all the categories in Level Two, which is wrong.  
I need to be able to show all the categories in Level Two, that have have the same categories field type.  The handle of this categories field type is topLevelConnection.
Any suggestions would be greatly appreciated!

**Tags:** categories, relations, category

---

## 1 answers

### Answer by username_0 on 2016-05-06. Score: 3

Turns out I was overthinking it, I was able to connect it with the following piece of code.
{% set levelOne = category.topLevelConnection %}
{% for subCat in craft.categories.group('levelTwo').relatedTo(levelOne) %}


---

