I have entries, which can have several categories. These categories are in different categorie groups.
Now if i show an entry page, i want to display i certain html block based on a specific category, the entry has or not.
i tried this, but its not working, i think i get the relatedTo thing wrong:
//i loop through all the categories in my group
{% for category in craft.categories.group('catGroup1') %}
//the i go to the section my entries are in and relate that to the categories i want to filter
{% set categoryListings = craft.entries({
section: 'kelims',
relatedTo: [
{ targetElement: category, field: 'filterThisCategory' }
]
}) %}
//if the entry has this category
{% if categoryListings|length %}
display some html block
{% endif %}
{% endfor %}
kelims
section. Could you tell me more about yourfilterThisCategory
field? A screenshot of the field settings would help. I'm also unsure I understood correctly what you try to achieve. You just want to output some HTML if the entry you're currently viewing has a specific category, right?