Next album's first picture

Hey all.
I searched a bit around but could not find the answer.

I've also looked into the source code, and tryed to put together a function to achieve this but that requires some deeper knowledge of how zenphoto is built.

This is what I need to:
On an image page, i need to replace the next and prev links so they point to the the first picture in the next album. Pointing them to the next album is wasy as there is already functions to do so.

I am comfortable with PHP, i just need a bit of help.

Thank you

Comments

  • There is no function to point to the first image of the next album. You will have to build that from the object model.
  • I can't really find the object model. But i am thinking about this quick hack:

    All functions and plugins seem to access whatever is necessary through $_zp_* globals.
    Assuming there is no method in $_zp_gallery that returns the next album (maybe it does, does it?), i thought about this.

    Getting the albums with
    $_zp_gallery->getAlbums();

    Then loop until i get my album and therefore know witch one is next and with one is previous.
    I'll come back if i have further questions or otherwise to share the snippet.

    Thank you
  • Sart here: http://www.zenphoto.org/category/User-Guide/ -- the second page has a guide on 'How to read the Zenphoto Functions Guide'.

    But since you said you were comfortable with PHP I presumed you could actually look at the objects themselves in the PHP code.
  • Ok, here it goes. It took me some time, but it was rather easy in the end. Neat application design :)

    It can be a bit tricky to follow the code because it's getting very extensive.
    I used phpxref to browse it, can't imagine how I would do without it.

    Anyway, here go the functions I used:

    `
    function getNextAlbumFirstPicture() {
    if(!in_context(ZP_IMAGE)) return false;
    global $_zp_current_album;
    $next_album = $_zp_current_album->getNextAlbum();
    if(empty($next_album)){ return null;}
    $image = $next_album->getImage(0);
    return rewrite_path("/" . pathurlencode($image->album->name) . "/" . urlencode($image->filename) . im_suffix(),
    "/index.php?album=" . urlencode($image->album->name) . "&image=" . urlencode($image->filename));
    }

    function getPrevAlbumFirstPicture() {
    if(!in_context(ZP_IMAGE)) return false;
    global $_zp_current_album;
    $prev_album = $_zp_current_album->getPrevAlbum();
    if(empty($prev_album)){ return null;}
    $image = $prev_album->getImage(0);
    return rewrite_path("/" . pathurlencode($image->album->name) . "/" . urlencode($image->filename) . im_suffix(),
    "/index.php?album=" . urlencode($image->album->name) . "&image=" . urlencode($image->filename));
    }
    `
Sign In or Register to comment.