1

Where entry.type is equal to meetingsEventsOverviewPage, I would expect the following to return true:

{{ entry.type starts with 'meetingsEvents' }}

And

{{ entry.type in ['meetingsEventsOverviewPage', 'meetingsEventsContactPage'] }}

However that doesn't happen.

If I test the string explicitly, it does work:

{{ 'meetingsEventsOverviewPage' starts with 'meetingsEvents' }}

And

{{ 'meetingsEventsOverviewPage in ['meetingsEventsOverviewPage', 'meetingsEventsContactPage'] }}

Is there some kind of parse order going on here that I need to know about?

2

Your problem is that entry.type is actually not a string, but an instance of EntryTypeModel. This means that entry.type is an object containing many different properties, among them the handle, which would be the property that you want to test in this case.

In other words, this should work:

{{ entry.type.handle starts with 'meetingsEvents' }}

Tip: When in doubt about the data your working with, or stuff not working like you'd think, it's often a good idea to dump:

{{ dump( entry.type ) }}

This will output all sorts of useful information about the data, e.g. what it actually is (String, Object etc), all its properties and methods etc.

1
  • Thanks. I hadn't tried inspecting it as in other cases it works just fine, presumably because it gets returned as a string, for example, these all work in that they return the handle: {% include '_partials/page_types/' ~ entry.type ignore missing %}, {% if entry.type == 'facilitiesDetailPage' %}. It was only when using 'in' or 'starts with' that I found the issue. Thanks for your help.
    – Russ Back
    Mar 3 '15 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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