Count days, is this page recent?

  Previous article Next article  

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');
  $smarty->assign('age', 'old');

  How to use

For use in the current page


{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>

Buy Me A Coffee

  Show related articles:

  Comment Form

Click here to open the form


No comments yet...

Buy Me A Coffee

CMS Made Simple - Tutorials, Tips and Tricks - CMSMS

Count days, is this page recent?

  Article optimized for CMSMS 2.x

  Last tested in: CMSMS 1.11.4
  Last updated: 23-06-2018
  Comments: 0

Buy Me A Coffee


Ads help me to help you! Buy products from these advertisers!