<p>Yes, you're right, one could call this a reverse-relation. The field you created the relation from is the "people" entry and you're looking at it from the category element's page.</p>

<p>To describe this direction in Craft <a href="http://buildwithcraft.com/docs/relations#the-relatedTo-param" rel="nofollow"><code>relatedTo</code></a> parameter, you define whether the element you're dealing with is the <a href="http://buildwithcraft.com/docs/relations#the-relatedTo-param" rel="nofollow"><code>sourceElement</code></a> of that relation, which means it is the element with the field, or if it is a <a href="http://buildwithcraft.com/docs/relations#the-relatedTo-param" rel="nofollow"><code>targetElement</code></a>, one of the elements selected in the field.</p>

<p>So on your "Our Skills" page you have a category element that <em>got</em> selected from a categories field, this makes it a <code>targetElement</code>. I'm also setting that categories field's handle here.</p>

<pre><code>{% set individuals = craft.entries({
    section: 'people',
    relatedTo: {
        targetElement: category,
        field: 'mySkillsFieldHandle'
    }
}) %}
</code></pre>

<p>In most cases you could just use the <code>element</code> property, because there are no other relations between both elements. But I actually like to always define my relations precisely, because who knows what we add to the site in the future, that potentially breaks loose definitions.</p>

CC BY-SA 3.0
2015-08-29T18:56:53.107Z
2015-08-29T18:56:53.107Z
carlcs
<p>I have a list of people with skills defined by a category group.</p>

<p>I have a category field within the '<strong>people</strong>' Section so when a new person (entry) is created, the category field allows the admin to assign appropriate <strong>skills</strong> to that new profile.</p>

<p>I have a series of category entries for the 'skills' available.</p>

<p>When a user visits an "Our Skills" entry page, I need to display the title (name) of the people who have had that particular skill assigned to their profile via the category field.</p>

<p>I think this is reverse relations but I can't get my head around it?</p>

<p>Would appreciate some help.</p>

<p>Many thanks</p>

<p>Martin</p>

<categories><relations>
Showing entries within a category
# Showing entries within a category

(Asked by: username_0 on 2015-08-29)

I have a list of people with skills defined by a category group.

I have a category field within the '**people**' Section so when a new person (entry) is created, the category field allows the admin to assign appropriate **skills** to that new profile.

I have a series of category entries for the 'skills' available.

When a user visits an "Our Skills" entry page, I need to display the title (name) of the people who have had that particular skill assigned to their profile via the category field.

I think this is reverse relations but I can't get my head around it?

Would appreciate some help.

Many thanks

Martin

**Tags:** categories, relations

---

## 1 answers

### Answer by username_1 on 2015-08-29. Score: 1 | Accepted answer

Yes, you're right, one could call this a reverse-relation. The field you created the relation from is the "people" entry and you're looking at it from the category element's page.
To describe this direction in Craft relatedTo parameter, you define whether the element you're dealing with is the sourceElement of that relation, which means it is the element with the field, or if it is a targetElement, one of the elements selected in the field.
So on your "Our Skills" page you have a category element that got selected from a categories field, this makes it a targetElement. I'm also setting that categories field's handle here.
{% set individuals = craft.entries({
    section: 'people',
    relatedTo: {
        targetElement: category,
        field: 'mySkillsFieldHandle'
    }
}) %}

In most cases you could just use the element property, because there are no other relations between both elements. But I actually like to always define my relations precisely, because who knows what we add to the site in the future, that potentially breaks loose definitions.


---

