Advanced search  

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]

Pages: [1]   Go Down

Author Topic: Thumbnail sort function by user defined field  (Read 5617 times)

0 Members and 1 Guest are viewing this topic.

AK_CCM

  • Coppermine regular visitor
  • **
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 63
  • Mushroom Hobby Photograph
    • Ent◊l◊ma.de – Rötlinge, Wiesenpilze und andere Schwammerln
Thumbnail sort function by user defined field
« on: February 09, 2006, 12:10:18 am »

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:

Code: [Select]
          'da' => 'pid ASC',
          'dd' => 'pid DESC',

to::

Code: [Select]
          'da' => 'user3 ASC',
          'dd' => 'user3 DESC',

But that is not the key...

Could anyone help me please?

regards, Andreas
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Thumbnail sort function by user defined field
« Reply #1 on: February 09, 2006, 06:21:05 am »

you'll have to modify that in the function get_pic_data

AK_CCM

  • Coppermine regular visitor
  • **
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 63
  • Mushroom Hobby Photograph
    • Ent◊l◊ma.de – Rötlinge, Wiesenpilze und andere Schwammerln
Re: Thumbnail sort function by user defined field
« Reply #2 on: February 09, 2006, 09:33:28 am »

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
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Thumbnail sort function by user defined field
« Reply #3 on: February 09, 2006, 10:07:09 am »

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

  • Coppermine regular visitor
  • **
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 63
  • Mushroom Hobby Photograph
    • Ent◊l◊ma.de – Rötlinge, Wiesenpilze und andere Schwammerln
Re: Thumbnail sort function by user defined field
« Reply #4 on: February 09, 2006, 12:55:33 pm »

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
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Thumbnail sort function by user defined field
« Reply #5 on: February 09, 2006, 02:13:38 pm »

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

  • Coppermine regular visitor
  • **
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 63
  • Mushroom Hobby Photograph
    • Ent◊l◊ma.de – Rötlinge, Wiesenpilze und andere Schwammerln
Re: Thumbnail sort function by user defined field
« Reply #6 on: February 09, 2006, 03:47:17 pm »

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:
Code: [Select]
        $user3 = addslashes($_POST['user3']);
to:
Code: [Select]
        $user3 = addslashes($_POST[strtotime('user3')]);
Could you help me please?
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Thumbnail sort function by user defined field
« Reply #7 on: February 09, 2006, 03:55:21 pm »

find a line starting with...
Code: [Select]
            $result = add_pictureabove add...
Code: [Select]
$user3=strtotime($user3);
of course user3 field shouldn't be of the type date anymore

AK_CCM

  • Coppermine regular visitor
  • **
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 63
  • Mushroom Hobby Photograph
    • Ent◊l◊ma.de – Rötlinge, Wiesenpilze und andere Schwammerln
Re: Thumbnail sort function by user defined field
« Reply #8 on: February 09, 2006, 07:13:40 pm »

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
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Thumbnail sort function by user defined field
« Reply #9 on: February 09, 2006, 07:24:04 pm »

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

you were supposed to leave it as varchar

AK_CCM

  • Coppermine regular visitor
  • **
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 63
  • Mushroom Hobby Photograph
    • Ent◊l◊ma.de – Rötlinge, Wiesenpilze und andere Schwammerln
Re: Thumbnail sort function by user defined field
« Reply #10 on: February 09, 2006, 07:37:36 pm »

you were supposed to leave it as varchar

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

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Thumbnail sort function by user defined field
« Reply #11 on: February 09, 2006, 07:40:52 pm »

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

AK_CCM

  • Coppermine regular visitor
  • **
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 63
  • Mushroom Hobby Photograph
    • Ent◊l◊ma.de – Rötlinge, Wiesenpilze und andere Schwammerln
Re: Thumbnail sort function by user defined field
« Reply #12 on: February 10, 2006, 02:52:25 am »

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
Logged

Stramm

  • Dev Team member
  • Coppermine addict
  • ****
  • Country: 00
  • Offline Offline
  • Gender: Male
  • Posts: 6006
    • Bettis Wollwelt
Re: Thumbnail sort function by user defined field
« Reply #13 on: February 10, 2006, 10:00:33 am »

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

  • Coppermine regular visitor
  • **
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 63
  • Mushroom Hobby Photograph
    • Ent◊l◊ma.de – Rötlinge, Wiesenpilze und andere Schwammerln
Re: Thumbnail sort function by user defined field
« Reply #14 on: February 15, 2006, 02:55:07 pm »

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)

Quote
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()

Very interesting, I'll try it out.
Logged
Pages: [1]   Go Up
 

Page created in 0.025 seconds with 20 queries.