Hope somebody can help us with this:
Objective: loop through a given Entry's "Related Entries" entry field and output the results - but group the results by the category to which they belong - not just a straight splurge of related entries.
Where we are:
{% for category in categories %}
<h2>{{ category.title }}</h2>{# spit out the Category #}
{% for relatedEntry in entry.relatedEntries %}
{{ relatedEntry.title }}{# this spits out all entries, but ignores whether the entry is related to the current category #}
{# So, try and check if it's related to the current category... #}
{% if relatedEntry.relatedTo(category) %}{# Trying to use this throws "Craft\EntryModel and its behaviors do not have a method or closure named "relatedTo"." #}
<p>{{ relatedEntry.title }}</p>
{% endif %}
{% endfor %}
{% endfor %}