Changing picture order in specific album Changing picture order in specific album
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Changing picture order in specific album

Started by Andy14, September 26, 2006, 09:28:25 AM

Previous topic - Next topic

0 Members and 3 Guests are viewing this topic.

Andy14

Hi there - is it possible to change the order of individual pictures in a specific album? By default, I sort my pictures according to the date they were added; however, in one album, I wish to sort them by file name - how would one go about changing the order of pictures in only an individual album, whilst retaining their default setting for the rest of the gallery?

xplicit

well anything is possible off course and I can think of 2 solutions but you need to have some knowledge of php and well the solution will only work for that specific album so it's more a hack for this function.

But here the suggestion:

Since that specific album has an unique album id you can simply make an if statement using this to determine if this is the special album for showing it for instance if the aid = 43


if ($aid = 43) {
sql = SELECT * ............... ORDER BY `mtime` DESC
etc etc...
} else {
the normal query
}


A somehow nicer aproach and how I would do it is to add an extra colum in the album table and call this for instance mode you can for instance set it default to 0 and for the special albums to 1. than make a statement which checks for the value of mode


if ($mode = 1) {
sql = SELECT * ............... ORDER BY `mtime` DESC
etc etc...
} else {
the normal query
}


I don't know if this can help you since I don't know your skills in programming so let me know

In this case you will only have to edit your database for those very special occasions and can leave the sourcecode the same






Don't ask me: Can you do this .... or Give me that...or I need Quick help in PM's. I'm not Santaclaus so post your questions on the board so it will be in the benefit for everyone.

Andy14

Thanks for the wonderful suggestions! I'm "so-so" at PHP and MySQL - I know enough to get by, the the second method sounds best, as I don't need to modify the source code. I'm sorry for my ignorance, but would you be able to post the exact code/details I will need to add to the table in PHPMyAdmin? Thanks so much!

xplicit

Quote from: Andy14 on September 26, 2006, 02:55:41 PM
the the second method sounds best, as I don't need to modify the source code.

well you still need to edit the source code but, I ment you dont have to edit the source code if you accidently want to add other albums in the future with the same feature.

so actually the second suggestion is more complicated
Don't ask me: Can you do this .... or Give me that...or I need Quick help in PM's. I'm not Santaclaus so post your questions on the board so it will be in the benefit for everyone.

xplicit

Ok well quick and dirty solution

(not tested since I dont have coppermine at the office only the source codes but it should work )

find out what the album number is you want to have the special behaviour

Open functions.inc.php in a text editor

find at line @946


if($select_columns != '*') $select_columns .= ', title, caption,hits,owner_id,owner_name';

$query = "SELECT $select_columns from {$CONFIG['TABLE_PICTURES']} WHERE ((aid='$album' $forbidden_set_string ) $keyword) $approved $ALBUM_SET ORDER BY $sort_order $limit";


change into (lets pretend the album has id 43

if($select_columns != '*') $select_columns .= ', title, caption,hits,owner_id,owner_name';
if($album == 43) $sort_order = 'filename ASC';

$query = "SELECT $select_columns from {$CONFIG['TABLE_PICTURES']} WHERE ((aid='$album' $forbidden_set_string ) $keyword) $approved $ALBUM_SET ORDER BY $sort_order $limit";


In case you want the titles descending use if($album == 43) $sort_order = 'filename DESC';

In case you want to have more albums use something like

if ($album == .... || $album == ... || $album == ...) $sort_order = 'filename ...';



Don't ask me: Can you do this .... or Give me that...or I need Quick help in PM's. I'm not Santaclaus so post your questions on the board so it will be in the benefit for everyone.

Andy14

Worked perfectly - thanks so much man, you're a life saver!

xplicit

Don't ask me: Can you do this .... or Give me that...or I need Quick help in PM's. I'm not Santaclaus so post your questions on the board so it will be in the benefit for everyone.