Member
Member
MarcelSpijker   2008-04-15, 11:24
#1

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 ...?

Administrator
Administrator
acrylian   2008-04-15, 13:25
#2

There is no function/option for that. This should work:
`if (hasNextImage()) {

} else {

$firstimage = $_zp_current_album->getImages(0);

echo "Next

}`

(Codetypos on purpose because the "damm" forum makes a real link out otherwise...)

Member
Member
gerben   2008-04-15, 13:39
#3

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));

}`

Member
Member
MarcelSpijker   2008-04-15, 14:01
#4

@acrylian: echo Next 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.

Member
Member
gerben   2008-04-15, 14:05
#5

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=""'

'a href=""'

This works fine.

Administrator
Administrator
acrylian   2008-04-15, 14:08
#6

@MarcelSpijker: Ah, sorry, that typo was without purpose..:-)

@gerben: Good one, too.

Member
Member
macalter   2008-04-15, 18:57
#7

Would these functions also work to add "first" and "last" image in addtion to prev/next?

Member
Member
gerben   2008-04-16, 13:02
#8

Yes, they just return a link to the first and the last picture.

Administrator
Administrator
acrylian   2008-04-19, 19:53
#9

As a note we have included both functions in the next nightly build.

  
Powered By MyBB, © 2002-2026 MyBB Group.
Made with by Curves UI.