Results 1 to 6 of 6

Thread: How to change the PHP Photo Album page links?

  1. #1
    Join Date
    May 2008
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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/dynamici...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.

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Sure, try replacing the original pagination links code:

    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:

    Code:
    <!--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>

  3. #3
    Join Date
    May 2008
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Spot on. Works a treat.

    Thanks!

  4. #4
    Join Date
    May 2008
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    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.

  5. #5
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Sure, simply wrap the for statement I had posted above with the if statement in red below:

    Code:
    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> ')
    }
    }

  6. #6
    Join Date
    May 2008
    Posts
    7
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Once again thanks so much. Really appreciated.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •