Quantcast
Channel: Zenphoto forum
Viewing all articles
Browse latest Browse all 2917

LondonLight.org on "How to jump to correct named anchor from index.php to image.php"

$
0
0

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:

<script type="text/javascript">
            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;
              }
            }
        </script>

(...)

<?php while (next_image()): ?>
  <div class="jump prev">
    <a href="#image_<?php echo (imageNumber() - 1);?>"><</a>
  </div>
  <div class="jump next">
      <a href="#image_<?php echo (imageNumber() + 1);?>">></a>
  </div>
  <a href="<?php echo html_encode(getFullImageURL());?>" title="<?php echo getBareImageTitle();?>" name="image_<?php echo imageNumber();?>"><?php printCustomSizedImage(getImageTitle(), NULL, NULL, NULL); ?></a>
<?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.


Viewing all articles
Browse latest Browse all 2917

Trending Articles