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
Hopefully album sorting will make it into the next version.
`// 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.
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.
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!
I guess I'll have to manually sort every album I upload until some sort of feature is implemented.
I understand that you are working on EXIF support, but would this also sort the albums?
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.