Hi,
I already read some forum posts about this topic and before I start to develop my own function I thought I should ask if I understood correctly:
Album Date: Date of an Album set
Image Date: Date of an Image (Taken from its Metadata)
printLatestAlbums() refers to "updateddate" in the DB, which is the last Date of an image?
Meaning:
There is nothing available to display " Last updated/last changed date"?This
`$filechangedate = strtotime($tempalbum->getUpdatedDate())`
confused me at first - because it seems its not really the "filechanged date" (meaning modified or creation date) but the date when the Image was taken?
What I would like to achieve:
*
Show the "date last updated" referring to the date when I last uploaded a new image (or edited the album?).
*
Sort the album based on the date I last changed Information / added an image.* Show Album/Image Date based on the metadata / admin backend setting
Maybe you have a recommendation how to do this?
Set the "updated date" manually in the DB each time I add an image or change information?
Or get the upload/file Date of the last image added? Or easier: the modification date of the album folder?(filetime)
Any help is highly appreciated
Thanks for all your work and support - Love ZenPhoto:)
Comments
Some explaination how Zenphoto uses these dates and what each order means:
- ID => discovery order from the file system, not necessarily the same as the date
- Date => Date uploaded, not necessarily matching the ID but mostly (and it can be changed). Imported from meta data if available and enabled.
- mtime => Is the file modification date. Folders actually don't have that. Albums use the date of the latest image for the updated date.
- updateddate => Albums only. The date you last added something to an album (title etc changes don't count)
- publishdate => is actually the date used for scheduled (un)publishing
Guess we should have a user guide entry for this… Changes to titles, descriptions or else made after uploading are not recorded. Only Zenpage news and pages have a lastupdate date for this currently.I'm still confused by updateddate which seems to be what I need...
I have actually the following case:
Album: Date set 4.7.2015
Images: Dates (of nearly all Images) 4.7.2015
-> Uploaded on 23.7 <- this is the date I would like to display (aswell) and use to sort albums.
But in the DB "updateddate" is 4.7.2015? OT: With filetime I was able to get the folder modificitaion date - so that helps a bit because its okay if it only considers new or edited images - not information.
But I would like to sort albums based on that - guess I will have to do that myself manually?
Or is there something wrong with my "updated" date since it doesn't seem to be the "last modified" date of an image?
Thank you very much!!
You could try to disable metadata importing for the date possibly to get the real mtime date.
Seems if I could get mtime I could achieve what I want - but lastimage always seems to be NULL here:?
`
$latestimage = query_single_row("SELECT mtime FROM " . prefix('images') . " WHERE albumid = " . $_zp_current_album->getID() . " AND 'show' = 1 ORDER BY id DESC");`
`
Thanks!
Edit: Just remembered this: http://www.zenphoto.org/support/topic.php?id=1409055 Does the new release does not include your fix from the support build? Thanks!
You normally should not use queries directly but the object model if you can avoid it. Try to add a `LIMIT 1` to the query. Note that`$latesimage` will be an array and not a plain variable. And also that mtime is stored as UNIX date and not as datetime xxxx-xx-xx.
it never reaches
`if ($latestimage) { echo "test";`
and
`var_dump($latestimage)` is `NULL`
(If I look at the DB mtime is set.)
Sorry to bother you so much with this issue - but maybe you have an idea what the problem could be
Thank you!
****UPDATE*****
Just found the "problem" myself - `show` is always set to `0` - and futhermore my albumids are messed up - that is why the statement always returns NULL - I will do a cleanup and see if it works then (Database reference Utility helped me - Seems `show </code) referes to "published" )`
That however should not really affect values of images themselves. To cleanup the database try the database refresh button on the overview page. That re-syncs filesystem with database entries for the gallery's albums.
Now I can display the date "last modified date" ` $lastUpdated = gmdate("Y-m-d\TH:i:s\Z", $latestimage["mtime"]); `
works.
The album column ` updateddate ` does not consider the mtime of the last image added (but its "date" set (metadata, manually set date,...) or modifications made to the album.
I noticed ` printLatestImagesByMtime ` calling ` getImageStatistic` provides this functionality by offering a sort.order by image.mtime.
Seems to work only for a specific album.
So in case anybody wants the same thing - I will write a custom function ` printLatestUpdatedAlbumsByMtime ` or something like that to sort albums and images by mtime and mtime displayed as "Latest Update."
Thank you!
`getAlbumStatistic()/printAlbumStatistic()` already support "latest-mtime" as a sort parameter for albums, just no actual named wrapper function exists for it (maybe we remove those anyway some day as they are not directly needed)
Exactly that's what I did. (This functionality is already provided in the great image_album_statistics PlugIn)
For the rest (sorting by latest image mtime) - Looks like this will get to complicated and I don't want to modify to much since the actual Object model is great. I'm happy for the moment with displaying the latest image mtime along the album and sort by the albums mtime!
Considering your explanation: Neither the albums mtime nor the updateddate take into consideration the actual upload date of an image (not the images date).
No idea if this is possible - or to complicated, but maybe one of those two dates could be modified when an new image is uploaded? (or better: the last publish date of an image, otherwise it wil mess up if an image is still not published)
Thank you for the great support and this great piece of software!!! I love ZenPhoto )))
But I had to click "Refresh Database" and "Perform Garbage Collection" which is great! Takes basically the change date of the album folder - my initial idea.
Now I was able to build a wrapper function that uses sorting by albums mtime.
I will think about it and maybe open on a ticket for such a function - maybe it would be better to use the publish date of an image - because it seems updated but the no new images appear could be confusing.
But for now its perfect and great with my little addition of displaying the latest image mtime
Thank yoo so much acrylian!