Sorting albums by date created Sorting albums by date created
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Sorting albums by date created

Started by Alexanderlejuez, March 11, 2014, 03:12:54 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Alexanderlejuez

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.

Αndré

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.

Alexanderlejuez

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

Αndré

The mod seems to work as expected, the albums are displayed in ascending order.

Alexanderlejuez

Yes, but I want it to display the most recent albums first. As in Descending by date. Is this possible?

Αndré

Sure, change
ORDER BY a.aid
to
ORDER BY a.aid DESC

Alexanderlejuez

Thanks for the amazing response time. This did solve my problem. Many thanks  ;D

Αndré

#7
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.