![]() |
|
prev next question - Printable Version +- ZenphotoCMS Forum (https://forum.zenphoto.org) +-- Forum: Support (https://forum.zenphoto.org/forum-1.html) +--- Forum: General support (https://forum.zenphoto.org/forum-4.html) +--- Thread: prev next question (/thread-2674.html) |
prev next question - MarcelSpijker - 2008-04-15 I want the next button to link to the first image of the album when the last image is showing. I don't see a function that give me the link to the first image. any ideas ...? prev next question - acrylian - 2008-04-15 There is no function/option for that. This should work: `if (hasNextImage()) { <print normal link to next image> } else { $firstimage = $_zp_current_album->getImages(0); echo "<ahreff='".getAlbumLinkURL().$firstimage.".php"'>Next</ae> }` (Codetypos on purpose because the "damm" forum makes a real link out otherwise...) prev next question - gerben - 2008-04-15 or you could possibly just add a function like getPrevImageURL() and call it getFirstImageURL() in template-functions.php, something like this I think: ` /** * Returns the url of the first image in current album. * * @return string */ function getFirstImageURL() { if(!in_context(ZP_IMAGE)) return false; global $_zp_current_album, $_zp_current_image; $firstimg = $_zp_current_album->getImage(0); return rewrite_path("/" . pathurlencode($firstimg->album->name) . "/" . urlencode($firstimg->filename) . im_suffix(), "/index.php?album=" . urlencode($firstimg->album->name) . "&image=" . urlencode($firstimg->filename)); }` prev next question - MarcelSpijker - 2008-04-15 @acrylian: echo `<ahreff='".getAlbumLinkURL().$firstimage.".php"'>Next</ae>` didnt work. i had to change $firstimage to $firstimage[0]. That did the trick thanks.@gerben: thanks for looking in to it, i decided to use acrylian's method because i will forget that i changed the functions file and with an update i will get lost This way it is easy for me to change if necessary.
prev next question - gerben - 2008-04-15 I actually just added this on my site, i just made that getFirstImageURL() function and similarly a getLastImageURL() function to get the url to the last image in the album. to get the last image I used: '$lastimg = $_zp_current_album->getImage($_zp_current_album->getNumImages() - 1);' and then I changed the links to the next and previous picture in image.php like this: 'a href="<?php if (hasPrevImage()){echo getPrevImageURL();} else{echo getLastImageURL();}?>"' 'a href="<?php if (hasNextImage()){echo getNextImageURL();} else{echo getFirstImageURL();}?>"' This works fine. prev next question - acrylian - 2008-04-15 @MarcelSpijker: Ah, sorry, that typo was without purpose..:-) @gerben: Good one, too. prev next question - macalter - 2008-04-15 Would these functions also work to add "first" and "last" image _in addtion_ to prev/next? <<First>> <<Prev>> <<Next>> <<Last>> prev next question - gerben - 2008-04-16 Yes, they just return a link to the first and the last picture. prev next question - acrylian - 2008-04-19 As a note we have included both functions in the next nightly build. |