Forum

Thread tagged as: Question, Addons, Gallery

Go to Previous/Next Album (Gallery App)?

I know it's possible to output links for previous and next image, within an album (https://docs.grabaperch.com/addons/gallery/page-functions/perch-gallery-adjacent-images/).

But is it possible to output links to previous and next album?

Ryan Anderson

Ryan Anderson 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes - how are you determining the current album at that point?

Thanks for the reply, Drew. I wasn't sure if it was in the documentation and I was just missing it.

I have created a page for each album and each page has this code, depending on what category I am trying to display, ie: Birds:

perch_gallery_album_listing(array( 'template'=>'list.html', 'image'=>true, 'filter'=>'category', 'match'=>'eq', 'value'=>'Birds' ));

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, so when you're displaying one album and need to determine the next, what code are you using to display the album?

This code in a "details.php" file:

$opts = array('template'=>'item.html');
perch_gallery_album(perch_get('item'), $opts);
Drew McLellan

Drew McLellan 2638 points
Perch Support

$current_album = perch_gallery_album(perch_get('item'), array(
                    'skip-template'=>true
                ));

// Next album
perch_gallery_albums(array(
    'sort' => 'albumOrder',
    'sort-order' => 'ASC',
    'count' => 1,
    'filter' => 'albumOrder',
    'match' => 'gt',
    'value' => $current_album['albumOrder']
    ));

// Previous album
perch_gallery_albums(array(
    'sort' => 'albumOrder',
    'sort-order' => 'DESC',
    'count' => 1,
    'filter' => 'albumOrder',
    'match' => 'lt',
    'value' => $current_album['albumOrder']
    ));

I added this code to my details.php but I receive a "undefined function perch_gallery_albums()" error on page load.

Were you meaning for me to add it there (or am I showing my clear lack of knowledge here)?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Which version of Gallery are you using?

2.8.2 - would the changes/fixes in 2.8.4 and 2.8.5 have any effect on the perch_gallery_albums() function?

Drew McLellan

Drew McLellan 2638 points
Perch Support

That function should already be present, so the error indicates something wrong with your installation. Updating would be a wise move.

Strange. Everything else works fine and the website has been up for months. I will have to leave it for now. Thank you for your help.