Body: <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>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-06T12:31:51.663Z
Comments.Text: You need to specify what the entry type are (unless you are getting the entry type "handle")
Comments.UserDisplayName: Martin
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-06T12:37:56.440Z
Comments.Text: How can i get a list of the entry type's handels?
Comments.UserDisplayName: Samuel E.
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-06T12:42:47.377Z
Comments.Text: 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.
Comments.UserDisplayName: Martin
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-06T12:48:31.997Z
Comments.Text: 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.
Comments.UserDisplayName: Samuel E.
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-06T12:58:14.393Z
Comments.Text: {% set entryTypes = section.getEntryTypes() %} should return an array of entryTypes
Comments.UserDisplayName: Martin
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2015-08-06T12:58:50.003Z
Comments.Text: you could loop over entryTypes and output them to see what you have i fin doubt.
Comments.UserDisplayName: Martin
Tags: <error-message><entry-type><array><segments>
Title: Checking if a value matches an entry type handle
ThreadText: # 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
  
  