Show a list of the recently updated pages

  Previous article Next article  

Show a list of the recently updated pages

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.1.1
  Last updated: 04-01-2016
  Comments: 1

Outputs a list of recently updated pages.
This code is forked from the CMS Made Simple {recently_updated} plugin which is originally made by Elijah Lofgren. At the existing CMSMS plugin it isn't possible to change the lay-out of the output. I needed it for my website though, so I created this UDT which gave me more flexibility.

User Defined Tag, named "recent_page_updates"
$number = isset($params['number']) ? $params['number'] : '10';
$dateformat = isset($params['dateformat']) ? $params['dateformat'] : 'd.m.y h:m';  

$gCms = CmsApp::get_instance();
$hm = $gCms->GetHierarchyManager();
$db = $gCms->GetDb();

$output = '<ul>';

// Get list of most recently updated pages excluding the home page
$q = "SELECT * FROM ".CMS_DB_PREFIX."content WHERE (type='content' OR type='link')
AND default_content != 1 AND active = 1 AND show_in_menu = 1
ORDER BY modified_date DESC LIMIT "
.((int)$number);
$dbresult = $db->Execute( $q );
if( !$dbresult ) {
  echo 'DB error: '. $db->ErrorMsg()."<br/>";
}
while ($dbresult && $updated_page = $dbresult->FetchRow())
{
  $curnode = $hm->getNodeById($updated_page['content_id']);
  $curcontent = $curnode->GetContent();
  $output .= '<li>';
  $output .= '<a href="'.$curcontent->GetURL().'">'.$updated_page['content_name'].'</a>';
  $output .= ' ( '.date($dateformat,strtotime($updated_page['modified_date'])).' )';
  $output .= '</li>';
}

$output .= '</ul>';

return $output;

  How to use

{recent_page_updates}
{recent_page_updates number=5 dateformat='d.m.y'}
Parameters
  • dateformat - Use the format you whish (php-date-format). Default setting is d.m.y h:m.
  • number - Number of updated pages to show. Default is 10.

By changing the "$output" lines in the UDT, you can change the lay-out of the output.

  Working example

http://historisch.zeijen.nu/


A2 Webhosting CMS Made Simple

  Comments

  Click here to leave a comment






This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)
  « Enter the CAPTCHA code (lower case)

Your IP address will be stored on submit. I reserve the right to change or delete your response without notice!
In case of abuse your IP address will be blocked!


Can I have your attention for a moment?

Did this tutorial help you solving a problem at your (clients) website and it saved you many hours of work? Great!!
Consider buying Rolf a cup of coffee in return! [ Click here ]


  1 Comment

CMS Made Simple 2.2.2 - Tutorials, tips and tricks - CMSMS 2.2.2

Show a list of the recently updated pages

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 2.1.1
  Last updated: 04-01-2016
  Comments: 1

A2 Webhosting CMS Made Simple