Sorting in 1.1

Hello people,

I was very happy to hear about the 1.1 release. Although it means that I have to change my theme (integrated in wordpress) slightly. While going through the new release I can't find how to reverse the sorting of (sub)albums.

I would like the newest albums on top.

I searched through the forum, but the relevant topics are related to previous releases, and I'm not PHP pro enough to feel confident changing to much code if i'm not sure i'm doing the right thing. So the question:

How do I reverse the sorting of (sub)albums in Zenphoto 1.1(!) (or where in the forum can I read the solution)

Cheers

Comments

  • In the admin edit page for the subalbum is a sorting selector. You can choose date, filename, title, and manual. There is no way sort order (low to high)of the first three options. If you click on the sort order link, you can drag and drop the albums into the sequence you wish.
  • Yeah I found those options. But it would be really great if Zenphoto would display the albums in my preferred order (newest on top) without me having to change the sort options. , or drag an album to the right place
  • Please put a ticket into the TRAC describing the feature and how you would like it to work.
  • This is just a hack, but it should do what you want in the meantime without breaking anything else. In the zp-core/functions.php file in the sortAlbumArray function, add this code (line 633):

    `$order = "";

    if($sortkey='date') {

    $order = " DESC";

    }`

    Edit the code on line 634 (now line 638) to read:

    `" ORDER BY " . $sortkey . $order);`

    instead of

    `" ORDER BY " . $sortkey);`

    This forces the results into a descending order when being pulled from the database if the sortkey is 'date'. Hopefully this helps.
  • err...sorry about that last bit. I accidentally left it an assignment statement rather than compare. Use `==` instead of `=` in `if($sortkey='date') {`.
  • Thanks a lot elderz! Works like a charm!
  • Glad to help. It might still be worth adding something to TRAC just so you don't have to do this again on the next release.
  • Implementation of sort-direction complete. Look for this in the 1.1.1 nightly build soon.
  • Great work!
  • Thanks, sbillard!
Sign In or Register to comment.