View Full Version : How to change the PHP Photo Album page links?
1) Script Title: PHP Photo Album script
2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/php-photoalbum.htm
3) Describe problem: Is it possible to change the Page Links below the Thumbs to show the total number of images per link i.e. if a layout of 3x2 has been chosen and there is a total of 14 images in the directory then each link would show as follows:
"1 to 6", "7 to 12" and "13 to 14"
Great script. Thanks.
ddadmin
05-28-2008, 10:12 PM
Sure, try replacing the original pagination links code:
<!--Below HTML code refers to the navigational links for the gallery-->
<div id="navlinks">
<script type="text/javascript">
for (i=1; i<Math.ceil(galleryarray.length/totalslots)+1; i++)
document.write('<a id="navlink'+i+'" href="javascript:jumptopage('+i+')\">Page'+i+'</a> ')
document.getElementById("navlink1").className="current"
</script>
</div>
with the below instead:
<!--Below HTML code refers to the navigational links for the gallery-->
<div id="navlinks">
<script type="text/javascript">
var itemsperpage=totalslots
for (i=1; i<Math.ceil(galleryarray.length/totalslots)+1; i++){
var start=(i==1)? i : itemsperpage*(i-1)+1
var end=(i==1)? itemsperpage : Math.min(galleryarray.length, start+itemsperpage-1)
document.write('<a id="navlink'+i+'" href="javascript:jumptopage('+i+')\">'+start+' to '+end+'</a> ')
}
document.getElementById("navlink1").className="current"
</script>
</div>
Spot on. Works a treat.
Thanks!
I know I'm asking a lot now ..... but is it easy to disable the links if there is (in this case) 6 or less images.
At the moment for example if there is only say 4 images in the folder I still get a page link that says "1 to 6".
Ideally I would like there not to be a Nav link if there is no second group of images.
Is this possible?
Thanks again.
ddadmin
05-29-2008, 12:07 AM
Sure, simply wrap the for statement I had posted above with the if statement in red below:
if (galleryarray.length>totalslots){
for (i=1; i<Math.ceil(galleryarray.length/totalslots)+1; i++){
var start=(i==1)? i : itemsperpage*(i-1)+1
var end=(i==1)? itemsperpage : Math.min(galleryarray.length, start+itemsperpage-1)
document.write('<a id="navlink'+i+'" href="javascript:jumptopage('+i+')\">'+start+' to '+end+'</a> ')
}
}
Once again thanks so much. Really appreciated.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.