I couldn’t help adding a little more functionality to it, but it will do what you want. I called it getDocuments() because it will get the most recent or the least recent (oldest) documents. You can sort by any date field (editedon, publishedon, createdon, pub_date, unpub_date) and in either direction using the &sort and &dir properties. It sets placeholders for all document fields (which is kind of overkill), so you could edit it to just set the one(s) you need.
In your case, you would call it like this (more or less):
[[getDocuments]]
<p>Site Last Updated: [[+get_documents.editedon]]
The snippet returns no output, so put it at the top of the page (or the top of the <body> section of the template if you want it on lots of pages) and put the placeholder tag wherever you want the date. You can format the date with output modifiers, if necessary.
If you set the &limit property to something greater than 1, the placeholders get indexes so you you can do this:
<p>Recent Documents
<br />Pagetitle: [[+get_documents1.pagetitle]]
<br />ID: [[+get_documents1.id]]
<br />Published: [[+get_documents1.published]]
<br />Last Edited on: [[+get_documents1.editedon]]
</p>
<p>
<br />Pagetitle: [[+get_documents2.pagetitle]]
<br />ID: [[+get_doduments2.id]]
<br />Published: [[+get_documents2.published]]
<br />Last Edited on: [[+get_documents2.editedon]]
</p>
I resisted the impulse to have it use a Tpl chunk, but you might want that for a more complex display.
/* getDocuments Snippet */
$sort = $modx->getOption('sort',$scriptProperties,'editedon');
$dir = $modx->getOption('dir',$scriptProperties,'DESC');
$limit = $modx->getOption('limit',$scriptProperties, 1);
$c = $modx->newQuery('modResource');
/* ignore deleted resources */
$c->where(array(
'deleted' => 0,
));
$c->sortby($sort,$dir);
$c->limit($limit, 0);
$resources = $modx->getCollection('modResource',$c);
if (empty($resources)) {
return 'No resources found';
}
$index = $limit > 1? 1 : '';
foreach($resources as $resource) {
/* set placeholders for all resource fields */
$modx->toPlaceholders($resource->toArray(),'get_documents' . $index , '.');
if ($limit == 1) break;
$index++;
}
return '';
I should say that you could also use getResources for this, but this might be easier to use for some people.