Answers.Body: <p>Your <code>pageType</code> variable isn’t a string, but an entry type model (i.e. an object). When treated as a string, Craft renders the entry type handle automatically as a convenience, but in other cases - like in comparisons such as this - you should use the <code>handle</code> attribute:</p>
  <pre><code>{% set pageType = entry.type.handle %}
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-02T19:34:23.147Z
Answers.Text: AHA the convenience! cheers
Answers.UserDisplayName: joomkit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-02T18:39:28.907Z
Answers.LastActivityDate: 2022-03-02T18:39:28.907Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>I am trying to get an entry type check on an array</p>
  <pre><code>    {% set landerArray = ['fundingLander','healthLander', 'projectLander', 'publicationLander'] %}
      {% set pageType = entry.type %}
      {% if pageType in landerArray %}
      &lt;p&gt; lander page&lt;/p&gt;
      {% else %}
      &lt;p&gt;not lander&lt;/p&gt;
      {% endif %}
  </code></pre>
  <p>If I use plain text</p>
  <pre><code>{% if 'fundingLander' in landerArray %}
  </code></pre>
  <p>It works, but if pass a variable in i get nothing.
  I'm guessing twig thinks that pageType is not a string?</p>
  
Tags: <templating><array>
Title: Twig in array not working as expected
ThreadText: # Twig in array not working as expected
  
  (Asked by: username_0 on 2022-03-02)
  
  I am trying to get an entry type check on an array
  
  ```
      {% set landerArray = ['fundingLander','healthLander', 'projectLander', 'publicationLander'] %}
      {% set pageType = entry.type %}
      {% if pageType in landerArray %}
      <p> lander page</p>
      {% else %}
      <p>not lander</p>
      {% endif %}
  
  ```
  
  If I use plain text
  
  ```
  {% if 'fundingLander' in landerArray %}
  
  ```
  
  It works, but if pass a variable in i get nothing.
  I'm guessing twig thinks that pageType is not a string?
  
  **Tags:** templating, array
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-03-02. Score: 2 | Accepted answer
  
  Your `pageType` variable isn’t a string, but an entry type model (i.e. an object). When treated as a string, Craft renders the entry type handle automatically as a convenience, but in other cases - like in comparisons such as this - you should use the `handle` attribute:
  
  ```
  {% set pageType = entry.type.handle %}
  
  ```
  
  > **Comments:**
  > **username_0**: AHA the convenience! cheers  
  
  ---
  
  