Child Page last modified date

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
fowlerat
Forum Members
Forum Members
Posts: 30
Joined: Mon Mar 07, 2011 1:02 pm

Child Page last modified date

Post 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
mrenigma
Forum Members
Forum Members
Posts: 48
Joined: Fri Aug 05, 2011 3:43 pm
Location: London, United Kingdom

Re: Child Page last modified date

Post 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.
~ Life is like water, every movement you make changes the way it flows ~
fowlerat
Forum Members
Forum Members
Posts: 30
Joined: Mon Mar 07, 2011 1:02 pm

Re: Child Page last modified date

Post by fowlerat »

Hi mrenigma,

Many thanks for your help. Exactly what I needed.

Best
Alan
User avatar
rotezecke
Power Poster
Power Poster
Posts: 411
Joined: Fri Apr 18, 2008 9:34 pm
Location: Nimbin, Australia

Re: Child Page last modified date

Post 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

Code: Select all

$node->modified
and call

Code: Select all

{menu childrenof="YourParentAlias" template="YourNewTemplate"}
i suspect you get the "list of that pages children" through {menu} anyway, no?
Post Reply

Return to “CMSMS Core”