I'm trying to set up a template that will group related entries by category, and display the category name and description for the first entry of each category set.
For example, this page will display an entry for a restaurant menu. The title and description for the menu are part of a single channel entry, followed by the items on the menu, which are all related entries from a products channel:
Menu Title
Menu Description
Appetizers
Item 1
Item 2
Item 3
Salads
Item 1
Item 2
Item 3
etc.
So my template code is like this:
{exp:channel:entries channel="menus"}
<h1>{menu_title}</h1>
{menu_description}
{menu_items}
Here's where I get stuck.
{/menu_items}
{/exp:channel:entries}
I can readily display the category info with the categories tag pair:
{menu_items:categories}
{category_name}
{/menu_items:categories}
What I can't seem to do is group them together, identify the first item etc.:
{menu_items:categories}
{if count == 1}<h2>{category_name}</h3>{/if}
<h3>{menu_items:product_name}</h3>
{/menu_items:categories}
I've tried several variations of the category_archive tag, as well as the Category Sorted Entries plugin, but to no avail.
I've also tried to back into it, by starting with the categories first, but it all get very convoluted, very quickly.
I feel like there has to be a more direct approach to sorting related records. Am I wrong?
Thanks,
ty