Forum
Can't figure out where to put pagination links for gallery
I have this code to show all albums and their contents on one page:
<ul id="albumdisplay">
<?php
$opts = array(
'skip-template'=>true,
'paginate'=>true,
'count'=>20,
'sort'=>'albumID',
'sort-order'=>'DESC'
);
$albums = perch_gallery_album_listing($opts);
foreach($albums as $album) {
$opts = array(
'template'=>'image-list.html'
);
perch_gallery_album($album['albumSlug'], $opts);
}
?>
</ul>
image-list.html is:
<perch:before>
<li class="gallery"><a href="<perch:gallery id="main" />" title="<perch:if exists="extraInfo"><perch:gallery id="extraInfo" /><perch:else /><perch:gallery id="albumTitle" /></perch:if>" id="<perch:gallery id="albumID" />"><img src="<perch:gallery id="albumimage" type="image" width="226" height="190" crop="true" />" alt="<perch:gallery id="albumTitle" />" height="190" width="226" /></a>
</perch:before>
<perch:if id="perch_item_index" match="neq" value="1">
<a href="<perch:gallery id="main" />" title="<perch:if exists="extraInfo"><perch:gallery id="extraInfo" /><perch:else /><perch:gallery id="albumTitle" /></perch:if>" class="gallery-images"></a>
</perch:if>
<perch:after>
<h2><a href="<perch:gallery id="main" />" class="album-title"><perch:gallery id="albumTitle" /></a></h2>
</li>
</perch:after>
Now, the page count works, but I can't get any pagination links to show... well, I can't figure out where to put them. Obviously not in image-list.html. It might be because it's late - am I being thick?
Are the values showing up in
<perch:showall />
?Well the paging is working as the content is being split over multiple pages, but I don't have any pagination links. What am I looking for with showall? item-listing.html seems to have no idea that paging exists
I need the paging at the album level rather than image level.
You're looking for
current_page
,next_url
etchttps://docs.grabaperch.com/docs/templates/pagination/
Nope, they don't show
Aha, think I may have sorted it with this after the rest on gallery.php:
Yep, that did it! It is amazing what a weekend away from the computer can do for your brain!
Lisa, I used your code as a starting point and I was able to get it working, however, the pagination shows up as many times per page as there are albums. My gallery is structured very similarly to yours and I pasted the pagination code after the other code for the gallery, like you mentioned. Do you have any ideas what I might be doing wrong from your experience?
OK, so my gallery.php looks like this:
and the album-paging template looks like this:
Does that help you at all?
image-list.html looks like this:
I imagine you have just put the pagination in the wrong place??
Brilliant! I didn't have the pager code inside
<perch:after>
tags. That's what did it. Thank you for posting your code. This thread definitely helped me figure it out.Glad I could help someone else out for a change :)