I have a matrix field with with multiple types. In a template I want to loop through all of the entries of that matrix field as you normally would. However, I also want to access a bit of data from a specific type and I can not figure out how to do it. Very frustrating. Definitely would have been a no brainer to do in craft 2.5.
The matrix field has a type of "Instructor" which is an entry type. The entry has a field of "FullName".
So I want to say, if there is an entry type of Instructors in the matrix field, then output the full name of each entry selected in the matrix field of type "Instructor".
I've tried various methods based on the matrix blocks documentation and nothing works. The closest I get is the ID of the matrix field entry. Here is one example that should explain what I'm attempting to do.
{% set classBlocks = entry.classBlocks %}
{% if classBlocks|length %}
{% set instructors = clone(classBlocks).type('instructors').all() %}
by <strong>
{% for instructor in instructors %}
{% if not loop.first %}, {% endif %}
{{ instructor.fullName }}
{% endfor %}
</strong>
{% endif %}
Is this even possible? Seems pretty simple. At least in craft 2.5 I could have just looped through the matrix field and if the type was 'instructors' loop through the instructor entries outputting their full name.