MENU

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');
}
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>

Buy Me A Coffee


  Show related articles:


  Comment Form

ReviewManager





Note: 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!

GDPR privacy disclaimer
This form will send me your email address and your IP address.
If you don't want that, don't use this form!

ReviewManager

  0 Comments

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

  Author:
  Last tested in: CMSMS 1.11.4
  Last updated: 23-06-2018
  Comments: 0
  http://cms.ms/WESD


Buy Me A Coffee




Advertisement


Ads help me to help you! Thanks!

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