Hey guys. Really enjoying ExpressionEngine so far. I wanted to get some of your thoughts on an interesting issue: I need to have a listing of all categories in a single photo gallery in EE. The idea was to have output the first picture in each category. I also needed to loop through all the categories, and generate a list of links for every entry for the lightbox I’m using (although that was no problem). It took a little bit of fiddling around, but here’s what I came up with:
{exp:gallery:categories gallery="test-gallery" orderby="entry_date" columns="3" rows="2"}
<div class="staff-wrapper"> <!-- staff wrapper but it has photos in it! -->
{category_row}
{row_start} {/row_start}
{row}
<div class="staff">
{exp:gallery:entries gallery="test-gallery" category="{category_id}" orderby="entry_date"}
<a href="{image_url}" rel="lightbox[{category}]">{thumb_url}
<h3>{category}</h3><p> <br />
{category_description}<br />
{/exp:gallery:entries}<br />
</div><!-- end staff --><br />
{/row}<br />
{row_end} {/row_end}<br />
{/category_row}<br />
</div><!-- end staff wrapper with photos in it! --><br />
{/exp:gallery:categories}That’s the part that generates all the first entries per category. I noticed that not using {entries} or {row} tags caused {exp:gallery:entries} to return only the first iteration of the loop, which turned out to be exactly what I wanted. I was honestly expecting for this not to work because I thought I might run into a problem with the parse order, but it’s working fine. I was able to use the first loop to populate the {category} tag for the entries loop. At least that’s what I think is happening.
So, is there a better way to do this? It works fine, but I couldn’t shake the feeling that I had stumbled upon a sort of jack leg solution. Any thoughts?
BTW I’m running 1.6.8, and here’s a link to the page(it’s under development and has a LOT of random testing garbage, excuse the mess!)