1

I'm building my first site with Craft, so this is a bit newbie question.

I've build a category with a some fields. How can I output all fields form the selected category on the current entry?

Thank you very much.

2

If you have a Categories field on your entry called myCategoryField, you can check if it has any Categories selected by going:

{% if entry.myCategoryField | length %}
    There are categories selected!
{% endif %}

If you want to loop through all of the selected categories for that field, you can do:

{% if entry.myCategoryField | length %}
    <ul>
        {% for category in entry.myCategoryField %}
            <li>{{ category.title }}</li>
        {% endif %}
    </ul>
{% endif %}

For more info you can read more in the templating section of the Categories field's documentation.

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.