coppermine-gallery.com/forum

Support => cpg1.5.x Support => cpg1.5 miscellaneous => Topic started by: Alexanderlejuez on March 11, 2014, 03:12:54 PM

Title: Sorting albums by date created
Post by: Alexanderlejuez on March 11, 2014, 03:12:54 PM
Hi all,

I am using coppermine version 1.5.18 and I have no categories created. I have all my albums in "no category". At the moment it is sorting albums from old to new. What I want is for it to sort by date created. I want the new albums to display first. I have searched on the forum and found the following:

Quote from: Αndré on March 01, 2012, 02:51:37 PM
Open index.php, find
ORDER BY a.pos, a.aid
and replace with
ORDER BY a.aid
(three times) to sort albums by date created.

I tried this, but is is still not working form me. I see no change.

Please advise. All help is appreciated.
Title: Re: Sorting albums by date created
Post by: Αndré on March 11, 2014, 03:33:05 PM
At first you should upgrade to the latest stable release (currently cpg1.5.26), as you're running a version with known security vulnerabilities.

Then, please post a link to your gallery, so we can have a closer look.
Title: Re: Sorting albums by date created
Post by: Alexanderlejuez on March 11, 2014, 04:41:33 PM
Thank you for your prompt reply. I have just finished updating to 1.5.26

Please find my link to my album below:

http://www.afmaruba.com/album

I hope you can help me to find a solution for the ordering.

With kind regards,


Alexander Lejuez
Title: Re: Sorting albums by date created
Post by: Αndré on March 11, 2014, 04:44:44 PM
The mod seems to work as expected, the albums are displayed in ascending order.
Title: Re: Sorting albums by date created
Post by: Alexanderlejuez on March 11, 2014, 04:55:39 PM
Yes, but I want it to display the most recent albums first. As in Descending by date. Is this possible?
Title: Re: Sorting albums by date created
Post by: Αndré on March 11, 2014, 04:57:51 PM
Sure, change
ORDER BY a.aid
to
ORDER BY a.aid DESC
Title: Re: Sorting albums by date created
Post by: Alexanderlejuez on March 11, 2014, 06:18:36 PM
Thanks for the amazing response time. This did solve my problem. Many thanks  ;D
Title: Re: Sorting albums by date created
Post by: Αndré on March 12, 2014, 01:43:30 PM
I wonder where you found that code part, as I cannot see any occurrence of
ORDER BY a.pos, a.aid
in the cpg1.5.26 version of index.php.

Instead, I found
        $sort_array = array(
            'ta' => "a.title ASC, a.aid ASC",
            'td' => "a.title DESC, a.aid DESC",
            'da' => "a.aid ASC",
            'dd' => "a.aid DESC",
            'pa' => "a.pos ASC, a.aid ASC",
            'pd' => "a.pos DESC, a.aid DESC",
        );
        //$sort_code  = isset($USER['sort'])? $USER['sort'] : $CONFIG['album_sort_order'];
        //$sort_order = isset($sort_array[$sort_code]) ? $sort_array[$sort_code] : $sort_array[$CONFIG['album_sort_order']];
        $sort_order = $sort_array[$CONFIG['album_sort_order']];

so I suggest to adjust the config value to your needs. It will save you the effort to re-apply the mod after each upgrade.

Unfortunately there's currently no configuration interface available, so you either need to adjust the value in your MySQL database with a tool like phpMyAdmin, or wait for the release of my "hidden features" plugin.

To change the sort order of albums, you can use the Hidden features plugin (http://forum.coppermine-gallery.net/index.php/topic,77314.0.html).