How to sort the albums

This is the bigest problem I had since installing ZenPhoto.

I have 16 albums but I can't sort them. I whant to set the las ones added on the first page.

I don't need them to sort by themselves by date or name, I can do that myself, just tell me ...how?

Comments

  • The albums should be sorted by reverse date. I.e. the newest added should appear first. The albums list is built in the constructor of the Gallery object, in classes.php. Search for // Gallery Class //. If you want, you can mess with the $albums array there to suit your needs.

    Hopefully album sorting will make it into the next version.
  • :) I got to that point

    `// Gallery Class //

    class Gallery {

    var $albums = NULL;

    var $theme;

    var $themes;

    function Gallery() {

    $albumdir = SERVERPATH . "/albums/";

    if (!is_dir($albumdir) || !is_readable($albumdir)) {

    die("Error: The 'albums' directory cannot be found or is not readable.");

    }

    $dp = opendir($albumdir);

    $albums = array();

    while ($file = readdir($dp)) {

    if (is_dir($albumdir.$file) && substr($file, 0, 1) != '.') {

    $albums[] = $file;

    }

    }

    // Reverse the order to make recently added albums first.

    $albums = array_reverse($albums);

    // Sorting here? Alphabetical by default.

    $this->albums = $albums;

    }

    function getAlbums($page=0) {

    if ($page == 0) {

    return $this->albums;

    } else {

    $albums_per_page = zp_conf('albums_per_page');

    return array_slice($this->albums, $albums_per_page*($page-1), $albums_per_page);

    }

    } `

    but what shell I do further? I'm a beginner in php.

  • I have the same problem, how can i solve it ?
  • In order to display your gallery in reversed order, you can look in the file zen/classes.php in the method sortAlbumArray() of the class Gallery. There is a line ksort($newAlbumArray), here it's on line 725

    Change ksort for krsort (notice the -r- for reverse).

    This is a quick hack. If you manually sort your gallery in the admin pages (using the cool ajax drag-n-drop feature), the whole gallery will get reversed in the mysql database. This is a wrong, you might want to temporaraly change krsort back to ksort to fix it if that happen to you.
  • trisweb Administrator
    herve, this is an old post, so sorting should be worked out. It would be nice to add a "reverse" to each of the sort options though; I'll think about that.
  • This issue has not been fixed for me. I just added a bunch of albums, one by one, by date the pics were made, and on every add I refreshed the database through the zen admin in order for zen to assign progressive id's to the albums following the date the albums were photographed.

    But nevertheless, they appear randomly. I have 1.0.3. I also noticed that when I add an album, the sort field in the database is set to NULL. It would be good if for every album ID, Zen assigned also a Sort ID of the same number.

    I now manyally sorted 63 albums so that the ID matches the sort field in database, and reversed the display with the krsort in the config.php

    But the problem is that for every album I insert, i must manually place it on the bottom of the sort order, so zen assignes a sort number in the database field.

    Why isn't there a "sort by upload date" or something? This really makes me crazy!
  • Just noticed that with the krsort instead of ksort, there is a bug with the ajax sort in the admin page. When I have krsort and change the order of one or more albums, Zen inverts ALL the sort numbers in the database and the gallery also has inverted album views.

    I guess I'll have to manually sort every album I upload until some sort of feature is implemented.
  • JayD Member
    In my album i have the latest album displayed first. When i add an album it is added at the bottom. I have a pretty long list of albums so i can't drag and drop the albums at once. Although i would like it to be done automatic, i can live with manual sorting. But it does would make it a lot easier if there was a 'Send to top' button.

    I understand that you are working on EXIF support, but would this also sort the albums?
  • trisweb Administrator
    I'd rework the sorting after implementing EXIF, yes -- Sort by any EXIF field, essentially, or by upload date, or image date, etc.

    I also realize the sorting interface is bad, especially when you have lots of albums, and I apologize for the inconvenience. That's something that will be redesigned for 1.1.
Sign In or Register to comment.