<pre><code>{% if '4' not in navigation.navi.ids() %}
    {% exit 404 %}
{% endif %}
</code></pre>

CC BY-SA 3.0
2015-06-19T11:50:52.617Z
2015-06-19T11:50:52.617Z
Bob Olde Hampsink
<p>Is it possible to check a matrix array for an ID?</p>

<p>I created a entries field which functions as a navigation.
Now if the user decides to remove one entry I want the specific template to return a 404</p>

<p><img src="https://i.sstatic.net/aOUb2.png" alt="enter image description here"></p>

<p>I thought something like (Assuming we are in the "Journalismus" template):</p>

<pre><code>{% for navi in navigation.navi %}
    {% if '4' not in navi.id %}
        {% exit 404 %}
    {% endif %}
{% endfor  %}
</code></pre>

<p>But that does pass the 404 always.</p>

<p>Or is there a better way to do this?</p>

<matrix><conditional><entries-field><id>
If loop contains id `X`
# If loop contains id `X`

(Asked by: username_0 on 2015-06-19)

Is it possible to check a matrix array for an ID?
I created a entries field which functions as a navigation.
Now if the user decides to remove one entry I want the specific template to return a 404

I thought something like (Assuming we are in the "Journalismus" template):
{% for navi in navigation.navi %}
    {% if '4' not in navi.id %}
        {% exit 404 %}
    {% endif %}
{% endfor  %}

But that does pass the 404 always.
Or is there a better way to do this?

**Tags:** matrix, conditional, entries-field, id


---

## 1 answers

### Answer by username_1 on 2015-06-19. Score: 3 | Accepted answer

{% if '4' not in navigation.navi.ids() %}
    {% exit 404 %}
{% endif %}


---

