2

I'm new to craft so this is a bit newbie question.

I have a category group with a set of categories, each category has a plain text field associated with it. The category group is then used as a field in a Matrix so the user can select one of the categories in the group. Basically all I want to do is list the plain text field from the selected category onto the page.

I tried working something out from https://craftcms.com/docs/relations (Going through a matrix section) but I just kept breaking everything. Any assistance would be appreciated!

Thanks.

2

Without knowing what your field handles are, this is the gist of how you’d do it:

{#
   Loop through each block within your Matrix field,
   assigning them to a `block` variable:
#}

{% for block in entry.myMatrixField %}

    {#
       Loop through each category within this Matrix block,
       assigning them to a `category` variable:
    #}

    {% for category in block.myCategoriesField %}

        {#
           Output the plain text field value:
        #}

        <p>{{ category.myPlainTextField }}</p>

    {% endfor %}

{% endfor %}

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.