I have two queries on related entries (using Many to Many plugin) to find both related and then reverse related entries:
{% set relatedArticles = article.relatedArticles %}
{% set reverseRelatedArticles = craft.entries.relatedTo(article) %}`
I want to merge these two ElementCriteriaModel, removing any duplicates before processing them further. I've tried this:
{% for item in reverseRelatedArticles %}
{% if item not in relatedArticles %}
{% set relatedArticles = relatedArticles|merge([item]) %}
{% endif %}
{% endfor %}
But it doesn't remove the duplicates. Adding find()
to the queries to turn them in to an array doesn't work either. Any way I can do this?
EDIT: I tried this, too:
{% set relatedArticles = article.relatedArticles.find()|merge(craft.entries.relatedTo(article).find()) %}