Hello all,
I want to display a message on the homepage of my new ModX site saying "This site was last updated on [Day] at [Time]".
Is there a simple way to do this in ModX?
All help welcome.
Cheers
Smaavie
Many thanks for telling me about the GetTime - it is almost perfect for my current purposes.
It seems to me that the GetTime snippet is ideal for displaying, on any given page, the date that this page was updated. However, I need a ’site-wide’ last updated date/time ... i.e. I need to show, on all pages, the date/time that the most recently updated page was updated.
I hope you can help.
Cheers
Smaavie
sirlancelot,
In short, I want to display the day/time that the most recent update was made to page that was most recently updated. (I hope that makes sense).
My plan is to put the snippet call into my template so that this value is shown on every page, in the form "This site was last updated on [Day] at [Time]".
Crucially, the same value should be displayed on all pages. (I don’t want to show the day/time when the current page was last update, I want to show the day/time when the last update was made to any page in the site).
I hope this clarifies my requirements a bit. Again, any advice would be appreciated.
Cheers
Smaavie
Hi splittingred
Thanks for the snippet. It worked without any problems at all, but it didn’t produce exactly the results I require.
The snippet shows the day/time that the current page was last updated. What I need is just one site-wide value for the day/time of the very last update, regardless of what page it was that was updated last.
(Sorry if this is not making any sense).
Cheers
Smaavie
ganeshXL,
Thanks so much for posting the snippet. It works perfectly, and produces exactly the results I want.
I really appreciate your help.
Cheers
Smaavie
Hey ganeshXL, care to put this nice little snippet in the repo?
thanks.
And along the similar lines I created this awhile ago for someone:
http://cmssandbox.com/MODx095/index.php?id=58
It is a snippet that will tell when the last page was created, sitewide. It was posted to the forums back in March.
<?php
/*
::::::::::::::::::::::::::::::::::::::::
Snippet name: LastCreation
Short Desc: Lists the time from the last creation of a document
Version: 1.0.0
Author: Jesse Rochman (Jesster444)
Date: March 7, 2007
Example Usage:
[!LastCreation!] - Outputs the the time in xx Days xx Hours xx Minutes. It will return the time of creation for the last document created, regardless of published status.
[!LastCreation? &lcPublished=`1` &lcParent=`10`!] - Outputs the time of creation for the last published document created that is a child of document 10.
Parameters:
&lcPublished: (0|1)
If set to 0 it will output the time for the last creation of an unpublished document, if set to 1 it will output the time for the last creation of a published document.
&lcParent:
The parent ID of the folder you want to look in for last creation times. Can be used in conjuction with $lcPublished.
::::::::::::::::::::::::::::::::::::::::
*/
if (isset($lcPublished) && $lcPublished < 2) {
$SQL = "published=$lcPublished";
}
else $SQL = '';
if (isset($lcParent) && $SQL) {
$SQL .= " AND parent=$lcParent";
}
elseif (isset($lcParent) && !$SQL) {
$SQL = "parent=$lcParent";
}
$table = $modx->getFullTableName("site_content");
$results = $modx->db->select("createdon", $table, "$SQL", "createdon DESC", "1");
$results = $modx->db->getRow($results);
$createdon = $results['createdon'];
if ($createdon) {
$now = time();
$diff = $now - $createdon;
$days = floor($diff/86400);
$hours = floor($diff/3600);
$minutes = floor($diff/60);
if ($days > 0) {
if ($days == 1) $output = $days . ' day ';
else $output = $days . ' days ';
$diff = $diff - ($days * 86400);
$hours = floor($diff/3600);
}
if ($hours > 0) {
if ($hours == 1) $output .= $hours . ' hour ';
else $output .= $hours . ' hours ';
$diff = $diff - ($hours * 3600);
$minutes = floor($diff/60);
}
else $minutes = floor($diff/60);
if ($minutes >0) {
if ($minutes == 1) $output .= $minutes . ' minute';
else $output .= $minutes . ' minutes';
}
return $output;
}
else return '';
?>
Jesse R.
Consider trying something new and extraordinary.
Illinois Wine
Have you considered donating to MODx lately?
Donate now. Every contribution helps.