Show date of last edit?
Permalink 1 user found helpful
Hello all
My existing site shows the date of the last edit at the bottom of some pages (e.g. 'Page last updated on 11/1/2010'). Is it possible to show this automagically in c5? Is it also possible to show the most up-to-date date on the homepage (ie. whenever the last update was made, regardless of which page it was made to)?
Many thanks :)
My existing site shows the date of the last edit at the bottom of some pages (e.g. 'Page last updated on 11/1/2010'). Is it possible to show this automagically in c5? Is it also possible to show the most up-to-date date on the homepage (ie. whenever the last update was made, regardless of which page it was made to)?
Many thanks :)
I've found these on the API reference:
and
but how do I show these? I'd like the first one on every page, and the second one on the homepage.
This doesn't work:
Any thoughts would be much appreciated :)
getVersionDateCreated ()
and
getSiteLastEdit ()
but how do I show these? I'd like the first one on every page, and the second one on the homepage.
This doesn't work:
<?php echo $c->getVersionDateCreated(); ?>
Any thoughts would be much appreciated :)
Thanks for the reply, it works great!
Is it possible to format the date string to something more attractive (and British!)? i.e. 14 Jan 2010
Also, can this be applied to show the edit dates of specific pages as well as the whole site?
Thanks :)
Is it possible to format the date string to something more attractive (and British!)? i.e. 14 Jan 2010
Also, can this be applied to show the edit dates of specific pages as well as the whole site?
Thanks :)
I've achieved the formatting of the date like this:
which works great.
Any thoughts on how to do this for individual pages?
EDIT: i tried to apply the logic to individual pages using getVersionDateCreated like this:
but that didn't work (it just shows 1 Jan 1970 1200AM.
Any thoughts would be much appreciated :)
which works great.
Any thoughts on how to do this for individual pages?
EDIT: i tried to apply the logic to individual pages using getVersionDateCreated like this:
but that didn't work (it just shows 1 Jan 1970 1200AM.
Any thoughts would be much appreciated :)
Any thoughts from those in the know?
This is pretty straightforward.
check out the date formatting, the key is that you cast a time represented as a string back to a unix timestamp which is the seconds since 1970 or something like that, then the first parameter on date lets you specify the format you want. I am partial to the one I posted above. Hope that helps.
check out the date formatting, the key is that you cast a time represented as a string back to a unix timestamp which is the seconds since 1970 or something like that, then the first parameter on date lets you specify the format you want. I am partial to the one I posted above. Hope that helps.
Thanks! That works perfectly! :)
Now if there was a decent wiki where little snippets like this could live, this could help other people instead of filling up the forum...
Now if there was a decent wiki where little snippets like this could live, this could help other people instead of filling up the forum...
Durr the code for the sitewide edit doesn't actually work :(
For the homepage (showing the last edit to the entire site) i have this:
but it's not updating. I just changed a page today (the 19th) but the homepage still shows the 16th :(
For the homepage (showing the last edit to the entire site) i have this:
but it's not updating. I just changed a page today (the 19th) but the homepage still shows the 16th :(
hm kinda sucks but you could do this:
$db = Loader::db();
$lastEdit = $db->getOne("SELECT MAX( cDateModified )
FROM Collections");
then use that as your strtotime($lastEdit) in the same way you are looking to use the api.
It is another query but it should cache? Issue is if you edit a page you might get the older cached value though but it might not, haven't tested but the easy query does work.
$db = Loader::db();
$lastEdit = $db->getOne("SELECT MAX( cDateModified )
FROM Collections");
then use that as your strtotime($lastEdit) in the same way you are looking to use the api.
It is another query but it should cache? Issue is if you edit a page you might get the older cached value though but it might not, haven't tested but the easy query does work.
Thanks for the response. That seems kinda messy, tho!
Why doesn't the other code work? It seems that it's there in the API so it should be possible to use it :/
Why doesn't the other code work? It seems that it's there in the API so it should be possible to use it :/
Anybody got any thoughts? Will this solution cache, and is it therefore viable?
EDIT: i just added a new page, and the date updated. I wonder if it only updates when new pages are added, rather than when small edits to existing pages are made?
EDIT: i just added a new page, and the date updated. I wonder if it only updates when new pages are added, rather than when small edits to existing pages are made?
Can anyone comment on this? I've just launched the site, but when I edit an existing page the 'Site last edited' date on the homepage doesn't update.
Any help would be much appreciated :)
Any help would be much appreciated :)
What happens if you clear your cache (i.e. Dashboard > Sitewide Settings > Debug > Clear Cache)?
Hi there
I actually didn't have the cache enabled, but once I enabled it and cleared it the wrong date was still displaying. Any other thoughts?
I actually didn't have the cache enabled, but once I enabled it and cleared it the wrong date was still displaying. Any other thoughts?
Can anyone help on this?
I'm using this code:
but it only updates when a new page is added, not when a new edit is made to any existing pages. Obviously the latter is most common so it makes sense for it to be included in the idea of 'getSiteLastEdit'.
Any help would be much appreciated :)
I'm using this code:
but it only updates when a new page is added, not when a new edit is made to any existing pages. Obviously the latter is most common so it makes sense for it to be included in the idea of 'getSiteLastEdit'.
Any help would be much appreciated :)
Works for me. Tx 55wd!
This will do!
<?php // Load Date Helper $date = Loader::helper("date"); // You may need to define $c global $c; // Get Blocks in Main area foreach($c->getBlocks('Main') as $b) { $bDate[$i] = $b->getBlockDateLastModified(); $i ++; } // Reverse Sort Date Array rsort( $bDate ); //Echo Date and Time Page last Edited echo $date->getLocalDateTime($bDate[0],$mask = 'm-d-Y g:i:s'); <?
You can use the Last Updated block
http://www.concrete5.org/marketplace/addons/last-updated/...
http://www.concrete5.org/marketplace/addons/last-updated/...
and I thought it might reflect the date of the last edit, my reasoning being that once the page is already set as public any edit which are made are therefore immediately public, but that wasn't the case when I experimented (which is fair enough.. just thought I would try it anyway!).
c5 must keep a record of the dates of edits for its versioning system, so is there an easy way to get that info out of the database for display?