Advanced Search

Results 1 to 6 of 6

Thread: 2 Scripts on same html file.

  1. #1
    Join Date
    Apr 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default 2 Scripts on same html file.

    1) Script Title: PHP Photo Album script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamici...photoalbum.htm

    3) Describe problem:
    Hi everyone,i have a question.i tested the script "PHP Photo Album script" and works very well,but i want to use this script twice on the same html file.(for other photos)
    The problem is when click on "page 2,3..." the thumbnails that appear are from the first gallery,probably because the two scripts have the same link for "next photos".
    What can i do?

  2. #2
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You could change the variable names and function names just a little bit to where the two scripts are different (variable and function wise).

    Hope this helps.
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  3. #3
    Join Date
    Apr 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    If change the variable names and function names i think the result will be the same,take a look at these lines:
    <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>
    The result of jumptopage('+i+') will be the same for the two scripts (2,3,4..etc) independent from the names of variables.

  4. #4
    Join Date
    Apr 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    No one??

  5. #5
    Join Date
    Sep 2006
    Location
    St. George, UT
    Posts
    2,769
    Thanks
    3
    Thanked 157 Times in 155 Posts

    Default

    You would have to change the function name "jumptopage" to something else as well. Use the following code where you want the second gallery to be displayed.

    getpics2.php
    Code:
    <?
    Header("content-type: application/x-javascript");
    
    function returnimages2($dir=".") {
       $patterns="\.(jpg|jpeg|png|gif|bmp)$";
       $file = array();
       $curimages=0;
       if($handles = opendir($dir)) {
           while(false !== ($theFile = readdir($handles))){
                   if(eregi($patterns, $theFile)){
    		 $filedates=date ("M d, Y H:i:s", filemtime($theFile));
                     echo 'galleryarray2[' . $curimages .']=["' . $theFile . '", "'.$filedates.'"];' . "\n";
                     $curimages++;
                   }
           }
    
           closedir($handles);
       }
       return($file);
    }
    
    echo "var galleryarray2=new Array();" . "\n";
    returnimages2();
    ?>
    The code that goes in the body:
    Code:
    <script src="getpics2.php" type="text/javascript"></script>
    
    <script type="text/javascript">
    
    /***********************************************
    * PHP Photo Album script-  Dynamic Drive DHTML code library (www.dynamicdrive.com)
    * Visit http://www.dynamicDrive.com for hundreds of DHTML scripts
    * This notice must stay intact for legal use
    ***********************************************/
    
    var dimensions="3x2" //Specify dimension of gallery (number of images shown), such as 4x2, 3x1 etc
    var imagepaths="http://www.mysite.com/gallery/" //Absolute path to image directory. Include trailing slash (/)
    var href_targets="new" //Enter target attribute of links, if applicable
    
    //Toggle popup link setting: popupsetting[0 or 1, "pop up window attributes" (if 1)]
    var popupsettings=[1, "width=500px, height=400px, scrollbars, resizable"]
    
    //Toggle image description: descriptionprefix[0 or 1, "Text to show" (if 1)]
    var descriptionprefixs=[1, "Photo "]
    
    //Sort images by date? ("asc", "desc", or "")
    //"desc" for example causes the newest images to show up first in the gallery
    //"" disables this feature, so images are sorted by file name (default)
    var gsortorders="desc"
    
    //By default, each image hyperlinks to itself.
    //However, if you wish them to link to larger versions of themselves
    //Specify the directory in which the larger images are located
    //The file names of these large images should mirror those of the original
    //Enter a blank string ("") to disable this option
    var targetlinkdirs="http://www.mysite.com/largegallery/"
    
    /////No need to edit beyond here///////////////////
    
    function sortbydates(c, d){ //Sort images function
    if (gsortorders=="asc") //sort by file date: older to newer
    return new Date(c[1])-new Date(d[1])
    else if (gsortorders=="desc") //sort by file date: newer to older
    return new Date(d[1])-new Date(c[1])
    }
    
    if (gsortorders=="asc" || gsortorders=="desc")
    galleryarray2.sort(sortbydate)
    
    var totalslot=dimensions.split("x")[0]*dimensions.split("x")[1]
    
    function buildimages(j){
    var imagecompletepaths=(targetlinkdirs!="")? targetlinkdirs+galleryarray2[j][0] : imagepaths+galleryarray2[j][0]
    var tempcontainers='<a href="'+imagecompletepaths+'" target="'+href_targets+'" onClick="return popuplinkfuncs(this)">'
    tempcontainers+='<img src="'+imagepaths+galleryarray2[j][0]+'" title="'+galleryarray2[j][0]+' ['+galleryarray2[j][1]+']" />'
    tempcontainers+='</a><br />'
    tempcontainers+=(descriptionprefixs[0]==1)? descriptionprefixs[1]+(j+1) : ""
    return tempcontainers
    }
    
    function jumptopages(pg){
    var startpoints=(pg-1)*totalslot
    var ys=1;
    for (j=0; j<totalslot; j++){
    document.getElementById("slides"+j).innerHTML=(typeof galleryarray2[startpoints+j]!="undefined")? buildimages(startpoints+j) : ""
    }
    while(document.getElementById("navlinks"+ys)!=null){
    document.getElementById("navlinks"+ys).className=""
    ys++
    }
    document.getElementById("navlinks"+pg).className="current"
    }
    
    var curimages=0
    for (y=0; y<dimensions.split("x")[1]; y++){
    for (x=0; x<dimension.split("x")[0]; x++){
    if (curimages<galleryarray2.length)
    document.write('<div id="slides'+curimages+'" class="slideshow">'+buildimages(curimages)+'</div>')
    curimages++
    }
    document.write('<br style="clear: left" />')
    }
    
    function popuplinkfuncs(imgsrcs){
    if (popupsettings[0]==1){
    var popwins=open(imgsrcs.href, "popwins", popupsettings[1])
    popwins.focus()
    return false
    }
    else
    return true
    }
    
    </script>
    
    <!--Below HTML code refers to the navigational links for the gallery-->
    
    <div id="navlinks">
    <script type="text/javascript">
    for (n=1; n<Math.ceil(galleryarray2.length/totalslot)+1; n++)
    document.write('<a id="navlinks'+n+'" href="javascript:jumptopages('+n+')\">Page'+n+'</a> ')
    document.getElementById("navlinks1").className="current"
    </script>
    </div>
    Tested, and works. Hope this helps
    "Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music." - Kristian Wilson, Nintendo, Inc, 1989
    TheUnlimitedHost | The Testing Site | Southern Utah Web Hosting and Design

  6. #6
    Join Date
    Apr 2007
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Sorry for delay "thetestingsite".First of all i would like to thank you VERY much for the interest,but there is a broblem.Are you sure it works if i paste the "new" code to my html file??It appears nothing.Have you forgotten anything?

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
  •