How to jump to correct named anchor from index.php to image.php

To make the question clear I have to explain what my site structure is like.

index.php has a box which shows the 5 newest images:
`printLatestImagesByMtime( 5, '', false, false, false, 40, '', 100, 100, NULL, false, false );`

image.php shows all images in the album:
`

var num = 1;
var imageCount = "<?php echo getTotalImagesIn($_zp_current_album); ?>";
document.addEventListener("keydown", jump, false);
function jump(e) {
var keyCode = e.keyCode;
if(keyCode==37) {
if(num > 1) num -= 1;
location.hash = "#image_" + num;
}
else if(keyCode==39) {
if(num < imageCount) num += 1;
location.hash = "#image_" + num;
}
}


(...)

<?php while (next_image()): ?>


" title="<?php echo getBareImageTitle();?>" name="image_<?php echo imageNumber();?>"><?php printCustomSizedImage(getImageTitle(), NULL, NULL, NULL); ?>
<?php endwhile; ?>
`
It's important to me to let users jump to the next/previous image using the left/right arrows, as well as to have clickable left/right arrows (the <div class="jump next/prev"> does that).

Please advise how to make it possible so that if I click on an image in index.php, I get taken not only to that image's album but also jump to that image's named anchor.

Maybe instead of numbering images I could use their names in the javascript, so instead of #image_1, #image_2, #image3 it would be #carrots, #cabbage#, #kitteh, but I don't know how to get this list of names.

Comments

  • acrylian Administrator, Developer
    Zenphoto has by default a concept of album pages (album.php) with thumbs and/or subalbums and the single image page (image.php). There are functions available for all these. See the theming tutorial and the functions documentation.

    If you wish to leave the standard way you may have to write your own functions to achieve that. Note also that rss feeds point on these standard pages depending on the rss feeds so you might need fallbacks for direct image links.

    If you want to use anchors to jump to you have to place links containing that and matching IDs on the page to jump to. You get the name via the `$_zp_current_image` global containing the image object. Please see the object model turorial I already mentioned elsewhere and the list of globals on the user guide.

    Note Zenphoot internally does not use the "mtime" for latest but the ID per discovery from the file system. You will get wrong lists if your image mtimes are not correct otherwise.

    You will hopefully understand that we neither can't teach you general web technique basics here nor help with too specific custom theme things.
Sign In or Register to comment.