I want to list a channel's entries by category. It's a kind of hybrid of using EE's category_archive tag but inside of exp:channel:entries. I have an ugly solution (shown here); it violates every DRY principle out there, but I don't know how to do it better.
The channel is a glorified list of links with explanation text and image.
The results I'd like to have:
Resource Page Title heading H1
Category A H2
Resource Link 1
Another Resource Link
And another
A different Category H2
Resource Link
Yet Another one
One more here
etc.
How the channel fields are set up:
{title} (obviously)
Channel fields
{resource_url_link} — Link to destination website
{resource_src_logo} — Destination website logo
{resource_rte_blurb} — Brief description of destination site
Note: {title_url} has no business in this channel. At all.
Option I considered but rejected:
Category Archive (link to EE Docs): Limited to only entry title and a path or entity akin to title_url, which will not work.
Ugly workable code/tags I'm using at the moment
(It is ugly, it violates DRY/Don't Repeat Yourself, but the total number of categories are limited so it's doable.)
For each category (see H2 tags), I hand-code category ID in the low_title item, and match that ID in the subsequent exp:channel:entries.
<h2>{exp:low_title:category category_id="7"}</h2>
{exp:channel:entries channel="resources" disable="pagination|member_data|category_fields" category="7"}
<div>
<div><img alt="{title}" src="{resource_src_logo:medium}"></div>
<div><h3><a href="{resource_url_link}">{title}</a></h3>{resource_rte_blurb}</div>
</div>
{/exp:channel:entries}
<h2>{exp:low_title:category category_id="10"}</h2>
{exp:channel:entries channel="resources" disable="pagination|member_data|category_fields" category="10"}
<div>
<div><img alt="{title}" src="{resource_src_logo:medium}"></div>
<div><h3><a href="{resource_url_link}">{title}</a></h3>{resource_rte_blurb}</div>
</div>
{/exp:channel:entries}
Do you know how I can do this better?