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?

1 Answer 1


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 %}
  • AHA the convenience! cheers
    – joomkit
    Commented Mar 2, 2022 at 19:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.