<p>I am trying to check if a value provided by the user (url segment) matches an entry type, and if not redirect to 404.</p>

<pre><code>{% set section = craft.sections.getSectionByHandle('shop') %}
{% set entryTypes = section.getEntryTypes('handle') %}
{% if not segmentEntryType in entryTypes|keys %}
    {% exit 404 %}
{% endif %}
</code></pre>

<p><code>segmentEntryType</code> is the string from the segment.
i get the error:</p>

<pre><code>An exception has been thrown during the compilation of a template ("Node "1" does not exist for Node "Twig_Node".").
</code></pre>

CC BY-SA 3.0
2015-08-06T12:31:51.663Z
You need to specify what the entry type are (unless you are getting the entry type "handle")
Martin
CC BY-SA 3.0
2015-08-06T12:37:56.440Z
How can i get a list of the entry type's handels?
Samuel E.
CC BY-SA 3.0
2015-08-06T12:42:47.377Z
If you go to settings->sections, that will show a list of all section and their handles. if you then click on edit entry type for a section (a channel section) it should give you a list of entry types and their handles.
Martin
CC BY-SA 3.0
2015-08-06T12:48:31.997Z
No, what i mean is that how can i put a list of the existing entry type's handles so i can check if `segmentEntryType` matches one of them, and if it desn't redirect to 404 page. thats what i'm trying to do.
Samuel E.
CC BY-SA 3.0
2015-08-06T12:58:14.393Z
{% set entryTypes = section.getEntryTypes() %} should return an array of entryTypes
Martin
CC BY-SA 3.0
2015-08-06T12:58:50.003Z
you could loop over entryTypes and output them to see what you have i fin doubt.
Martin
<error-message><entry-type><array><segments>
Checking if a value matches an entry type handle
# Checking if a value matches an entry type handle

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

I am trying to check if a value provided by the user (url segment) matches an entry type, and if not redirect to 404.
{% set section = craft.sections.getSectionByHandle('shop') %}
{% set entryTypes = section.getEntryTypes('handle') %}
{% if not segmentEntryType in entryTypes|keys %}
    {% exit 404 %}
{% endif %}

segmentEntryType is the string from the segment.
i get the error:
An exception has been thrown during the compilation of a template ("Node "1" does not exist for Node "Twig_Node".").

**Tags:** error-message, entry-type, array, segments

> **Comments:**
> **username_1**: You need to specify what the entry type are (unless you are getting the entry type "handle")  
> **username_0**: How can i get a list of the entry type's handels?  
> **username_1**: If you go to settings->sections, that will show a list of all section and their handles. if you then click on edit entry type for a section (a channel section) it should give you a list of entry types and their handles.  
> **username_0**: No, what i mean is that how can i put a list of the existing entry type's handles so i can check if `segmentEntryType` matches one of them, and if it desn't redirect to 404 page. thats what i'm trying to do.  
> **username_1**: {% set entryTypes = section.getEntryTypes() %} should return an array of entryTypes  
> **username_1**: you could loop over entryTypes and output them to see what you have i fin doubt.  

---

## 0 answers

