<p>Yes, it looks like the <code>descendantOf</code> param doesn’t accept an array of element models or array of element IDs. Here’s what you can do in Twig to work around the problem.</p>

<p>This solution does trigger an additional query for every parent entry matching your <code>relatedTo</code> criteria. But as it’s only fetching the <code>ids</code> column, it might not perform too bad actually, depends on the amount of matching parent entries though.</p>

<pre><code>{% set idsParam = [] %}
{% for parent in parents %}
    {% set idsParam = idsParam|merge(parent.getDescendants().ids()) %}
{% endfor %}

{% set children = craft.entries({
    section: 'training',
    ids: idsParam,
    eventDate: '&gt;= ' ~ now|date('U'),
    order: 'startDate DESC',
}) %}
</code></pre>

CC BY-SA 3.0
2018-02-08T20:11:46.470Z
2018-02-08T20:11:46.470Z
carlcs
<p>I want to select all children of all entries that fulfil specified relation parameter.</p>

<p>I have tried this, but I think .isDescendantOf only supports single entry. Is this even possible?</p>

<pre><code>{% set parents = craft.entries.section('training').level('1').relatedTo(relationParam) %}
{% set children= craft.entries.section('training').isDescendantOf(parents).eventDate('&gt;= ' ~ now).order('startDate DESC') %}
</code></pre>

<hr>

<p>I thought giving more background to this might help, as possibly an entirely new approach will be necessary. Consider this setup in Craft CMS
<a href="https://i.sstatic.net/SGOre.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/SGOre.png" alt="enter image description here"></a>
I have a 2 level structure, where top level is a big matrix describing an event and has quite a big classification section where multiple categories are selected. Then it's children are specific instances of that event with their own date and location. </p>

<p>I don't want to force my client to repeat categorization on each of the lvl2 entries since they've already done it on lvl1. </p>

<p>Can I select all lvl2 entries that have parents fulfilling specific relation param?</p>

CC BY-SA 3.0
2018-02-08T19:43:45.780Z
Would you mind using php for that? It's relatively easy with php (twig filters) but it will become really nasty with twig
Robin Schambach
<entries><relations><structure>
Find structure entries which parents relate to other entries
# Find structure entries which parents relate to other entries

(Asked by: username_0 on 2018-02-07)

I want to select all children of all entries that fulfil specified relation parameter.
I have tried this, but I think .isDescendantOf only supports single entry. Is this even possible?
{% set parents = craft.entries.section('training').level('1').relatedTo(relationParam) %}
{% set children= craft.entries.section('training').isDescendantOf(parents).eventDate('>= ' ~ now).order('startDate DESC') %}


I thought giving more background to this might help, as possibly an entirely new approach will be necessary. Consider this setup in Craft CMS

I have a 2 level structure, where top level is a big matrix describing an event and has quite a big classification section where multiple categories are selected. Then it's children are specific instances of that event with their own date and location. 
I don't want to force my client to repeat categorization on each of the lvl2 entries since they've already done it on lvl1. 
Can I select all lvl2 entries that have parents fulfilling specific relation param?

**Tags:** entries, relations, structure
> **Comments:**
> **username_1**: Would you mind using php for that? It's relatively easy with php (twig filters) but it will become really nasty with twig  

---

## 1 answers

### Answer by username_2 on 2018-02-08. Score: 2 | Accepted answer

Yes, it looks like the descendantOf param doesn’t accept an array of element models or array of element IDs. Here’s what you can do in Twig to work around the problem.
This solution does trigger an additional query for every parent entry matching your relatedTo criteria. But as it’s only fetching the ids column, it might not perform too bad actually, depends on the amount of matching parent entries though.
{% set idsParam = [] %}
{% for parent in parents %}
    {% set idsParam = idsParam|merge(parent.getDescendants().ids()) %}
{% endfor %}

{% set children = craft.entries({
    section: 'training',
    ids: idsParam,
    eventDate: '>= ' ~ now|date('U'),
    order: 'startDate DESC',
}) %}


---

