Thumbnail sort function by user defined field Thumbnail sort function by user defined field
 

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

Thumbnail sort function by user defined field

Started by AK_CCM, February 09, 2006, 12:10:18 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

AK_CCM

Hello all,

I'm creating an mushroom image gallery with CPG for our association.

I use the user3-field for the finding date of the mushrooms. Now I want to sort the thumbnails with a click of the date-buttons by the user3-field.

I've tried to change the get_pic_data function:

          'da' => 'pid ASC',
          'dd' => 'pid DESC',


to::

          'da' => 'user3 ASC',
          'dd' => 'user3 DESC',


But that is not the key...

Could anyone help me please?

regards, Andreas

Stramm

you'll have to modify that in the function get_pic_data

AK_CCM

Hello Stramm,

if I change the function in get_pic_data, CPG sorts the thumbs only by day. Month and year of the finding date will be ignored.

I think I must change the type of the user3-field in the db from varchar(255) to date(10)? But after that modification the format of the date on the imagedisplay-view is yyyy-mm-dd instead of the german like dd.mm.yyyy - how could I adjust this?

Regards, Andreas

Stramm

true, german date format using varchar will give you strange results.

either you'll have to modify the query (add SELECT DATE_FORMAT(...)). But that's not recommended

best is (depending where you display the date) to convert the date to a unix timestamp (with strtotime()) and then use date() or the cpg function  localised_date() to convert the time to a data in the euro format. With the CPG function it's easy to use the config setting for the date display -> localised_date($timestamp, $album_date_fmt) -> coppermine will convert it to the language specific date format. If you browse your gallery in german -> german date format (defined in lang/german.php)

AK_CCM

Okay, I will try it out. But my knowledge about PHP & MySQL isn't good.

To convert the date with strtotime() I must change an entry in upload.php? To save an UNIX timestamp I must modify the user3-fiel in the db back to varchar(255)?

Thanks forward

Regards, Andreas

Stramm

if you have the possibility then I'd save the 'date' as unix timestamp. This can be easily sorted. Before displaying it anywher on your page you can use localised_date($timestamp, $album_date_fmt)

AK_CCM

Sorry for my inconvenience. I think I understand the part to localise the date. But I don't know how to get the timestamp of the finding date in the user3-field of the db.

I'll try to explain. When I make an upload, I 1st choose an image and then I make my file information entries such as the finding date in german date format (user3). But I must change a pice of code in upload.php to store the user3-entry as timestamp in the db?

Perhaps this one:
        $user3 = addslashes($_POST['user3']);

to:
        $user3 = addslashes($_POST[strtotime('user3')]);

Could you help me please?

Stramm

find a line starting with...
            $result = add_picture
above add...
$user3=strtotime($user3);

of course user3 field shouldn't be of the type date anymore

AK_CCM

After the modification in upload.php and an upload the user3-field (varchar(255)) in the db contents -1.

And after I changed the format of user3 to date(10) the finding date values have been deleted. :-[

I think I give it up...

Regards, Andreas

Stramm

Quote from: Stramm on February 09, 2006, 03:55:21 PM
of course user3 field shouldn't be of the type date anymore

you were supposed to leave it as varchar

AK_CCM

Quote from: Stramm on February 09, 2006, 07:24:04 PM
you were supposed to leave it as varchar

I made the change after my 2nd posting in this thread - one test to much.

Stramm

just test what you have so far. Three test finding date values should be enough.

AK_CCM

Hello again,

after a break I've tried it again. The -1 value in the user3-field results from the german date format which I wrote in the upload dialog - my mistake. When I tried a date format like yyyy-mm-dd it works fine and also the sort function in the thumbnail view. Next I'll try to change the view of the finding date from timestamp to german date format...

Is it much work to modify CPG so that it extracts the finding date from the filename e.g. pvak_antrodia_serialis_01_2006-02-02.jpg and inserts the date automatically into the user3-field?

Regards, Andreas

Stramm

where let you coppermine display the 'finding date'?

it's easy to extract the date out of the filename. Depending on the delimiter (eg _ or |, best is they don't usually appeare in the filename... therefore ___ isn't to bad at all -> pvak_antrodia_serialis_01___2006-02-02___.jpg) use preg_split() or explode(). Best to implement it where you've added strtotime()

AK_CCM

Quote from: Stramm on February 10, 2006, 10:00:33 AM
where let you coppermine display the 'finding date'?

- on the page with the midsize image view, film strip and file information (displayimage.php)
- on the page to edit the file information (editOnePic.php)

Quoteit's easy to extract the date out of the filename. Depending on the delimiter (eg _ or |, best is they don't usually appeare in the filename... therefore ___ isn't to bad at all -> pvak_antrodia_serialis_01___2006-02-02___.jpg) use preg_split() or explode(). Best to implement it where you've added strtotime()

Very interesting, I'll try it out.