Skip to content

Instantly share code, notes, and snippets.

@jamiepittock
Created September 3, 2014 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jamiepittock/2635516e95317e5c6ed6 to your computer and use it in GitHub Desktop.
Save jamiepittock/2635516e95317e5c6ed6 to your computer and use it in GitHub Desktop.
{% set topicsGrouped = craft.entries.section(portal.topicsHandle).limit(null).order('slug') | group('slug | first') %}
<div class="index">
{% for letter, topics in topicsGrouped %}
<div class="index__item">
<div class="index__letter">{{ letter | upper }}</div>
<div class="index__list">
<ul>
{% for topic in topics %}
{#
{% set group = craft.categories.group(portal.topicsHandle).relatedTo(topic).first() %}
#}
{% set group = topic.businessTopicGroup.first() %}
<li>
<a href="/{{ topic.uri }}">{{ topic.title }}</a>
{% if group is not empty %}<span>{{ group }}</span>{% endif %}
</li>
{% endfor %}
</ul>
</div>
</div>
{% endfor %}
</div>
@maxxst
Copy link

maxxst commented Sep 3, 2014

I would need more information about the entries but my first idea would be -> get one big query outside the for-loop and then only loop throug the results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment