Hello, I recently started learning octobercms, I’m switching from wp. Following the example of tailor blueprints from the demo theme, I created items and categories. Now I wanted to display items of the same categories as the current item, but I can’t figure out how to do it. Can you explain, help me how to do this, or direct me to where it is written about
{% if item.categories %}
<div class="content">
<h2>Related:</h2>
<ul class="catalog-item-list" >
{% set output_items = [] %}
{% for cat in item.categories %}
{% set relateditems = catalog.whereRelation('categories', 'slug', cat.slug).paginate(0) %}
{% if relateditems %}
{% for relateditem in relateditems %}
{% if relateditem.slug not in output_items and relateditem.slug != item.slug %}
{% set output_items = output_items|merge([relateditem.slug]) %}
{% partial 'katalog/item-card' item=relateditem %}
{% endif %}
{% endfor %}
{% endif %}
{% endfor %}
</ul>
{% endif %}
Is this a normal solution or is there a more correct one?