Well, backing way up to the concept of having per-entry photo galleries. The most efficient way I know if is to use the Matrix Add-on from Pixel and tonic. Matrix allows you to add multiple, variable number of rows of things to one entry.
I’m using it here on our travel site:
http://boyinks4adventure.com/our-travels/badlands/
Everything you see on that page - the text, the photos, the videos and the map are all contained in one entry. Collectively it all gets stored in one channel.
What that doesn’t allow is a gallery to be re-used across posts, which your approach does allow (not sure if that was a requirement).
- EE can use either category id or category url titles in the URL. Thats a choice you make as developer.
- You could possibly use category custom fields to store meta information.
- One thought is to do the following. Move your gallery display code into it’s own template (I’ll call it ‘display_category_thumbs’). Tweak the code to be the following:
<ul class="gal">{exp:channel:entries channel="gallery" disable="trackbacks|member_data|pagination" category="{embed:my_category_id}" sort="asc" dynamic="no"}
<li class="{switch="rbmgn|rbmgn|bmgn"}">
<a href="http://{title_permalink=prints/view}">_ {pri-gal-thumb}_ </a>
</li>{/exp:channel:entries}
</ul>
Note how I’ve removed the hardcoded category info and replaced it with a variable. That variable needs to get passed from the parent loop. You didn’t post that code so let me make some up:
{exp:channel:entries channel="content_page"}
{title} {!-- standard content fields --}
{body}
{if {page_gallery !-""} {!-- Look to see if a gallery id has been entered on this page}
{embed="embeds/display_category_thumbs" my_category_id="{page_gallery}"} {!-- call in the embedded template but pass the id of the gallery to display as an embed variable for embedded templates --}
{/if}
{/exp:channel:entries}
Note the embed will get called once for every iteration of the loop - so this approach is fine on a single entry page. If the parent template was displaying >1 entry from the “content_page” channel you’d get >1 galleries returned.