Results 1 to 5 of 5

Thread: Source Order problem with PHP Album Script

  1. #1
    Join Date
    Oct 2010
    Posts
    5
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Source Order problem with PHP Album Script

    1) Script Title: PHP Photo Album script v2.11

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

    3) Describe problem: I have successfully set up this on one of my websites with no problem, however now that I'm using a different host, I cannot get the right "Sort Order" for my uploaded pictures. One server goes:

    Source Order: 1
    Source Order: 2
    Source Order: 3
    and so on

    the other
    Source Order: 3
    Source Order: 1
    Source Order: 24
    Source Order: Photo #
    and so on

    The photos seem to be in the right order but not the source which will not allow me to easily set a description for each. Does this have something to do with the Server or am I doing something wrong? The exact same files are on both servers, only the source order messes up in one of them.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Generally the source order can be ignored. The 1st description will go with the first image, the second description with the second image, and so on. The source order may vary because the images were found in the order in which they were uploaded to the server. Once they are sorted by the script, everything should work out.

    If this is not happening, it might be the host. But it might be some difference in the script you've missed, or a bug in the script.

    If there really is a problem and you have the same images and code on both servers, give us a link to both of them so we can check it out.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    Sonico67 (05-17-2011)

  4. #3
    Join Date
    Oct 2010
    Posts
    5
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Host#1
    Host#2

    Both html files are within the same server so I'm using the exact same scripts on both, I only changed both paths where the images are being hosted. getalbumpics.php within pictures folders is also the same. For now I will have to host the images/scripts on Host#1 and the code on Host#2.

  5. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    It's a bug in the script. The script is sorting the array after the descriptions are assigned, so if the files weren't already in the final order (as in the case of Host#2) everything gets out of order. In ddphpalbum.js replace its function phpimagealbum with this one:

    Code:
    function phpimagealbum(setting){
    	this.albumvar=setting.albumvar
    	this.albumvar.images.pop() //remove last "dummy" array element
    	this.albumdivid='phpphotoalbum'+(++phpimagealbum.routines.albumcount)
    	this.dimensions=setting.dimensions || [3,3]
    	this.sortby=setting.sortby || ["file", "asc"],
    	this.autodesc=setting.autodesc
    	this.showsourceorder=setting.showsourceorder
    	this.onphotoclick=setting.onphotoclick || function(){}
    	this.photodivs=[] //array referencing each DIV that contains a slide
    	this.navlinks=null //HTML collection
    	if (setting.sortby[0]=="file") //sort by filename (asc)
    		this.albumvar.images.sort(function(a,b){return a[1].localeCompare(b[1])})
    	else //sort by date (asc)
    		this.albumvar.images.sort(function(a,b){return new Date(a[2])-new Date(b[2])})
    	if (setting.sortby[1]=="desc"){
    		this.albumvar.images.reverse()
    	}
    	for (var i=0; i<this.albumvar.images.length; i++){
    		if (this.albumvar.desc[i]) //if a manual desc exists for this image
    			this.albumvar.images[i][3]=this.albumvar.desc[i] //extend image array with desc
    	}
    	this.buildgallery()
    	this.buildnav()
    }
    In case you're interested, the highlighted part is where the descriptions get assigned. It had been above the section where things get sorted, much closer to the beginning of the function. I moved it to just after the sorting, so its descriptions will go with the new sort order.

    Speaking of the sort order, on index2.html, the sort order will not change (it's dictated by the sorting method and the order in which the files were uploaded to Host#2), but the descriptions will now each be with the proper image.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  6. The Following User Says Thank You to jscheuer1 For This Useful Post:

    Sonico67 (05-17-2011)

  7. #5
    Join Date
    Oct 2010
    Posts
    5
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Hey that was good! Host #1 is still fine while Host#2 now has the right description along with the images. The source order really doesn't matter to me as I remove it but it's the only thing that seemed to be wrong as I thought it went along with the description. Thanks!

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
  •