I have a suitability
category field in my product type that allows the content writer to select which categories this product is associated with.
But my issue is that on the product page I need to show a full list of these 'suitability' categories with a "yes" or "no" next to them indicating which categories are appropriate.
So I am getting the 'suitability' category group:
{% set suitability = craft.categories.group('suitability').all() %}
Then I am simply looping over this list, but I'm unsure how to format my if statement to dictate if this category needs a "yes" or a "no". I know it's probably something to do with the .relatedTo()
parameter but I'm not quite sure on the formatting.
{% for category in suitability %}
<dt class="data-list__item data-list__item--title">{{ category.title }}</dt>
<dd class="data-list__item data-list__item--value">
{% if product.relatedTo(category) %}Yes{% else %}No{% endif %}
</dd>
{% endfor %}
Thanks!