Subalbum sorting

I have implemented sorting for Subalbums that mimics the sorting for Albums. Of course, no Admin interface yet, but you can set the sort_order field via SQL or (at least with my ISP) the phpMyAdmin interface.

Replace the
getSubAlbums function in class-album.php with the code below:
`

function getSubAlbums($page=0) {

function sortSubalbumArray($albums)

global $_zp_gallery;

if (is_null($this->subalbums)) {

$dirs = $this->loadFileNames(true);

$subalbums = array();

foreach ($dirs as $dir) {

$dir = $this->name . '/' . $dir;

$subalbums[] = $dir;

}

$sortedSubalbums = $_zp_gallery->sortAlbumArray($subalbums);

$this->subalbums = $sortedSubalbums;

}

if ($page == 0) {

return $this->subalbums;

} else {

$albums_per_page = zp_conf('albums_per_page');

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

}

}

`

Comments

  • It's not working for me.

    Parse error: syntax error, unexpected T_GLOBAL, expecting '{' in /home/******/public_html/photos/zen/class-album.php on line 101
  • Probably a transcription error. Download the efferevescence_simpleviewer theme from the WIKI, the function is included in the copy of class-album.php included with the theme.
  • Hello,

    The sorting is not working for me. It's not the same sorting as the one with the previous function, but it's still not sorted as I want.

    I tried to put a value in the sort_order field but it's still not sorted.

    What should I do if I want my subalbums sorted by folder name ?

    Thanks.
  • sbillard, Keep up the good work with this! ZP Lives!
  • zittoune: You need the subalbum support hacks that are included in the effervescence_simpleviewer theme. See the readme file in the download.

    The sort only goes on the sort_order field, so you will have to order that the way you want your subalbums to appear.
  • Ok I'll try that, thank you for your answer sbillard :)
  • Couldn't test it before. The sort_order field is working fine :), I just didn't know how to use it.

    Thank you sbillard :)
Sign In or Register to comment.