Count days, is this page recent?

  Previous article Next article  

Count days, is this page recent?

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 1.11.4
  Last updated: 13-01-2015
  Comments: 0

With this User Defined Tag you can calculate the age of a content page and use it in your page/template to show a notice or style some text. This article originates from the former CMSMS Wiki and the original author is Jean-Sebastien Monzani.

User Defined Tag, named "page_recent"
$manager = cmsms()->GetHierarchyManager();

$thisPage = isset($params['pageid']) ? $params['pageid'] : cmsms()->variables['content_id'];

$currentNode = &$manager->sureGetNodeById($thisPage);
$currentContent =& $currentNode->getContent();

$nbdays = (time()-strtotime($currentContent->GetModifiedDate())) / 86400;

/* Update in the last month? */
if ($nbdays <= 31)
{
  $smarty->assign('age', 'new');
}
else
{
  $smarty->assign('age', 'old');
}

  How to use

For use in the current page

{page_recent}

{if $age == 'new'}<p>This page is recently updated</p>{/if}
{if $age == 'old'}<p>The page content is older then 31 days</p>{/if}
<h2 class"{$age}">Title of the page</h2>

Read the age of another page

{page_recent pageid='54'}

{if $age == 'new'}<p>The other page is recently updated</p>{/if}
{if $age == 'old'}<p>The other page content is older then 31 days</p>{/if}
<p class"{$age}">Status of the other page</p>

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 ]


  0 Comments

No comments yet...

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

Count days, is this page recent?

  Article optimized for CMSMS 2.x

  Author:
  Last tested in: CMSMS 1.11.4
  Last updated: 13-01-2015
  Comments: 0

A2 Webhosting CMS Made Simple