forum.coppermine-gallery.net

Support => cpg1.3.x Support => Older/other versions => cpg1.3 Miscellaneous => Topic started by: Andy14 on September 26, 2006, 09:28:25 am

Title: Changing picture order in specific album
Post by: Andy14 on September 26, 2006, 09:28:25 am
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?
Title: Re: Changing picture order in specific album
Post by: xplicit on September 26, 2006, 01:00:33 pm
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

Code: [Select]
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

Code: [Select]
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






Title: Re: Changing picture order in specific album
Post by: Andy14 on September 26, 2006, 02:55:41 pm
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!
Title: Re: Changing picture order in specific album
Post by: xplicit on September 26, 2006, 03:17:24 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
Title: Re: Changing picture order in specific album
Post by: xplicit on September 26, 2006, 03:45:07 pm
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

Code: [Select]
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
Code: [Select]
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 ...';



Title: Re: Changing picture order in specific album
Post by: Andy14 on September 29, 2006, 02:41:20 am
Worked perfectly - thanks so much man, you're a life saver!
Title: Re: Changing picture order in specific album
Post by: xplicit on September 29, 2006, 06:16:41 pm
Your welcome.

Topic can be closed.