Take the 2-minute tour ×
Craft CMS Stack Exchange is a question and answer site for administrators, end users, developers and designers for Craft CMS. It's 100% free, no registration required.

I have a 'teacher' channel section on my site. That channel has three entry types, 'teacher', 'demoTeacher' and 'guestTeacher' - how do I display entries from teacher and demoTeach combined? At the moment I'm showing one type like this:

{% for teacher in craft.entries.find({section: 'teacher', type: 'demoTeacher'}) %}

Secondly, how can I use a conditional that checks for entry type? I need do something like the following (pseudocode):

{% if entrytype is demoTeacher %}
    display read more button
{% endif %}
share|improve this question

1 Answer 1

up vote 4 down vote accepted

You can set the ElementCriteriaModel's type parameter to multiple values by passing it an array of entry type slugs:

{% set teachers = craft.entries.section('teacher').type(['teacher', 'demoTeacher']) %}

Use the type property on the entry model to access its entry type in your conditional (also see this list for other available properties).

{% for teacher in teachers %}

    {{ teacher.title }}

    {% if teacher.type == 'demoTeacher' %}
        ...
    {% endif %}

{% endfor %}
share|improve this answer
    
Thanks - that works. Any idea how to use a conditional to test for entry type? –  Daryl Knight Sep 3 at 22:06
    
Sure I have! :) –  carlcs Sep 3 at 22:08
    
Excellent - thanks matey :) –  Daryl Knight Sep 3 at 22:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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