Manual sorting?

I've gotta preface this by saying: thanks, Tristan, for this fantastic program! Even in beta, I like it MUCH better than everything else I've tried.

On to the question:

Per the ZenPhoto web page, I already know that sorting is planned for a future release. Until then, is there a way to manually "force" the sorting of albums on the index page? Such as modifying the album creation date, or something?

Comments

  • trisweb Administrator
    Sort of... the way PHP returns the array of files is based on creation time. So upload in the reverse order you want them (first uploaded files will be last).

    There's not really a way to modify this after you've uploaded, so it's not really good for sorting. I'll try to get that in the next version...
  • I second this request! Maybe you can make some wacky ajax drag and drop sorting thing-a-ma-bob!
    Or, I'd just settle for textboxes for numbers...

    :-)
  • Me too.

    One idea: Could ZP respect the order the files are numbered in, as in 1.jpg, 2.jpg...etc, or 2003.jpg, 2345, jpg.

    If that could be done, one could rearrange them via ftp renaming. For now...

    This would make it possible to have a photo that stays at the bottom, 9999999.jpg for example, and one that stays at the top of a gallery.
  • trisweb Administrator
    Some great sorting interface will be available for 1.0, just not yet ;-)

    I know, it's really bugging me too, and that just means it'll be done faster.
  • sorting would be amaaazing. doesn't even have to be AJAX, just anything.
  • php has a number of bult in functions for sorting arrays. so for instance if you wanted to sort your images alphabetically you could add a line like sort($images); to the get_image function
  • Yeah, natcasesort is probably a better bet. Stick this in at line 311 of classes.php:

    natcasesort($images);

    This'll give you basic natural alphabetical sorting, which works pretty well for most image names. Especially if you have just pulled them off a digital camera.
  • adding natcasesort($images); worked great for sorting the images, but it did something weird where some pictures would be skipped when i would go through an album from one picture to another, so i had to take it back out for now. any idea why that happened?
  • Yeah, I noticed that too. The natcasesort fix works for the Albums view, but the next/prev links don't work correctly. I'll look into it.
  • trisweb Administrator
    It may be the indexing in the array... it's pretty hacky how it's done, but essentially, the entire album is an array which is loaded each time, and the next/prev just use the index of the current in that array. So make sure it's always sorted the same way I guess.
  • Yeah, that was it. Since we're using the numerical index of the array to get the next/prev images, we need to store the new array values, without the previous keys. So, after the while loop in getImages, insert this:

    natcasesort($images);

    // Store the result so we don't have to traverse the dir again.
    $this->images = array_values($images);

    Note: the last line replaces the previous storing of the array. That'll solve the next/prev links problem.
  • excellent! works perfectly. thanks.
  • well it doesn't work for me.
    i added the following lines:

    natcasesort($images);
    //$this->images = $images;
    $this->images = array_values($images);

    but the albums on the index pages are still in an order i can't recall
  • This fix was only to sort the images in an album, NOT the albums in the main index page of the Gallery.
  • well how does zenphoto sort the index page?
    and is there a way to change this?
  • Check out my post in the Status topic for some good news on manual sorting!

    http://www.zenphoto.org/support/topic.php?id=138
Sign In or Register to comment.