I have a check box field called requiredPrograms, in it it has a selection of programs you can choose from. This is within a matrix field called Work shop Instructor which is for my workshop channel.

On my outside workshop page I'd like to display what programs are required for all the teachers at the workshop in the one spot. On the inner page they would be broken into separate programs per instructor.

I've done the inner page with no issue but I cannot figure out a way to do the outer one.

{% for block in entry.workshopInstructor[0] and entry.workshopInstructor[1] %}
   {% if block.requiredPrograms.contains('Photoshop')%}
   {% endif %}
{% endfor %}

That is my current attempt but this results in nothing being displayed and other attempts have only produced the output twice.

Any suggestions?

  • What does entry.workshopInstructor[0] and entry.workshopInstructor[1] refer to? – Mats Mikkel Rummelhoff Jun 11 '15 at 7:29
  • @mmikkel It refers to the matrix field that I am trying to access. I'd like to check block[0] and block[1] to see if the checkbox Photoshop has been selected. If it is selected on either one I'd like it to display. – JeffTalbot Jun 12 '15 at 0:15

The question is a little unclear, is this what you are looking for?

{% set requiredProgram = false %}
{% for block in entry.workshopInstructor %}
   {% if block.requiredPrograms.contains('Photoshop')%}
      {% set requiredProgram = true %}
   {% endif %}
{% endfor %}

{% if requiredProgram %}
  Photoshop is enabled on one of this entry's blocks field.
{% endif %}
| improve this answer | |
  • The requiredProgram tag refers to a checkbox field that contains multiple entries. If any of the instructors inputted into the matrix field have a software, I'd like it to display on the main page, but separately on their own inner pages. So this code works for the inner page {% for block in entry.workshopInstructor[0] %} {% if block.requiredPrograms.contains('Photoshop') %} foo {% endif %} {% endfor %} But won't work for the outer page So I need to somehow check if any of the entries have the checkbox ticked and if they do display the software. – JeffTalbot Jun 12 '15 at 0:19
  • At first I didn't understand the solution but with a slight bit of codification it works great. Thanks – JeffTalbot Jun 18 '15 at 4:15

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.