Page 1 of 1
Child Page last modified date
Posted: Fri Oct 12, 2012 1:31 pm
by fowlerat
Hi,
I have a summary page where I need to show a list of that pages children (which I've done), but also need to show the last modified date of each of the children. Any ideas please?
Many thanks
Re: Child Page last modified date
Posted: Sat Oct 13, 2012 12:44 am
by mrenigma
Hi Fowlerat,
I'd say you're probably going to need to add a UDT, something similar to this possibly?:
Code: Select all
$alias = (!empty($params['alias']) ? $params['alias'] : false);
$assign = (!empty($params['assign']) ? $params['assign'] : false);
// If alias is set
if (!empty($alias)) {
// Load defaults
global $gCms;
$contentOps =& $gCms->GetContentOperations();
$smarty =& $gCms->GetSmarty();
// If content operations could be loaded
if (!empty($contentOps)) {
// Set second option to false if you want inactive pages to be shown
$content = $contentOps->LoadContentFromAlias($alias,true);
// Retrieve the last modified timestamp
$timestamp = $content->GetModifiedDate();
// If assign is set, then set smarty variable otherwise just return the timestamp
if ($assign)
$smarty->assign($assign, $timestamp);
else
return $timestamp;
}
}
Save this as last_modified in your UDT's and then you can call it like this:
Code: Select all
{last_modified alias=$alias assign="timestamp"}
This method will return only the timestamp though, so you will want to use Smarty's format date (see
smarty docs) to format it correctly.
Re: Child Page last modified date
Posted: Sat Oct 13, 2012 11:57 am
by fowlerat
Hi mrenigma,
Many thanks for your help. Exactly what I needed.
Best
Alan
Re: Child Page last modified date
Posted: Sat Oct 13, 2012 10:58 pm
by rotezecke
Not that I tried this but I think you can use {menu} to
1) e.g list only children of current page
2) list the last modified date with it.
Create (copy) a new template that also prints
and call
Code: Select all
{menu childrenof="YourParentAlias" template="YourNewTemplate"}
i suspect you get the "list of that pages children" through {menu} anyway, no?