Moderator’s note: Moved to Howto.
Hello, I am having a problem making the pagination in my gallery work as intended.. Now I have managed to get a half working solution but I would like something better if possible.
I used the gallery template solution from http://www.5pieces.com/blog/alternative-gallery-template/
that uses categories as albums on the index page and then has another template for the thumbnails and the big photo in one place.
but since I really wanted to have pagination for my thumbnails I had to resort to the following solution:
{exp:gallery:entries gallery="{gallery_name}" orderby="date" sort="asc" dynamic="off" category="{segment_4}" limit="20"}
<h2>{category}</h2>
{centries}
{row}
{if segment_5 ==''}
<a href="{id_path={gallery_template}/category/}{category_id}/#photosmain" title="{title}"><img src="{thumb_url}" width="{thumb_width}" height="{thumb_height}" alt="{title}"/></a>
{/if}
{if segment_5 =='P0'}
<a href="{id_path={gallery_template}/category/}{category_id}/P0#photosmain" title="{title}"><img src="{thumb_url}" width="{thumb_width}" height="{thumb_height}" alt="{title}"/></a>
{/if}
{if segment_5 =='P20'}
<a href="{id_path={gallery_template}/category/}{category_id}/P21#photosmain" title="{title}"><img src="{thumb_url}" width="{thumb_width}" height="{thumb_height}" alt="{title}"/></a>
{/if}
{/row}
{/entries}
{paginate}
<p>Page {current_page} of {total_pages} pages {pagination_links}</p>
{/paginate}
{/exp:gallery:entries}
so what it does now is checks for the url segment and then supplies the link, since I will most likely never have more than around 40 photos for one gallery this does work, but I was hoping a more flexible solution could be made. The same thing is done for the next and previous entries right below the thumbnails. Here is the code for it:
{exp:gallery:entries gallery="{gallery_name}" dynamic="on" limit="1" log_views="off"}
<h1>
{exp:gallery:prev_entry gallery="{gallery_name}"}
{if segment_5 ==''}
<a href="{path={gallery_template}/category/}{category_id}#photosmain"><img src="/images/continue3.gif" alt=""/></a>
{/if}
{if segment_5 =='P0'}
<a href="{path={gallery_template}/category/}{category_id}/P0#photosmain"><img src="/images/continue3.gif" alt=""/></a>
{/if}
{if segment_5 =='P21'}
<a href="{path={gallery_template}/category/}{category_id}/P21#photosmain"><img src="/images/continue3.gif" alt=""/></a>
{/if}
{/exp:gallery:prev_entry}
{title}
{exp:gallery:next_entry gallery="{gallery_name}"}
{if segment_5 ==''}
<a href="{path={gallery_template}/category/}{category_id}#photosmain"><img src="/images/continue4.gif" alt=""/></a>
{/if}
{if segment_5 =='P0'}
<a href="{path={gallery_template}/category/}{category_id}/P0#photosmain"><img src="/images/continue4.gif" alt=""/></a>
{/if}
{if segment_5 =='P21'}
<a href="{path={gallery_template}/category/}{category_id}/P21#photosmain"><img src="/images/continue4.gif" alt=""/></a>
{/if}
{/exp:gallery:next_entry}
</h1>
<div class="clear"><img src="{image_url}" width="{width}" height="{height}" alt="{title}" id="photo" class="slicka4" /></div>
<div class="clear">{if caption}<p>{caption}</p>{/if}</div>
<div class="photosdetails">
<span>Date added: {entry_date format="%d/%m/%Y"}</span>
<span>Camera model: {custom_field_two}</span>
<span>This image has been viewed {views} {if views == 1}time{/if}{if views != 1}times{/if}</span>
</div>
</div>
{/exp:gallery:entries}
I am also wondering why the page number is 20 instead of 1 or 2 or 3…does the gallery module make the page number depending on the limit of entries per page because that what it seems to be doing now. if I limit my entries to say 15 then I have to update the if segment parts to reflect that as well. So all of this works…but I am wondering why the code has to be so messy to achieve such a simple task. Maybe I am missing out on something?
And last but not least, I would like it that there is no previous entry link on the first photo in the gallery as well as there not being a next entry link on the last photo. I have it working properly in weblogs so I’m not really sure why the gallery doesn’t have a start and end but rather just starts from the beginning when you get to the end and vice versa.
I hope this isn’t too complicated for you to figure out. This is my last problem before I can finally put my site online ![]()
ps of course there is also the problem that if you’re on the last big picture from the first page of thumbnails and you click on the next entry the thumbnails won’t change to the second page
