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>

Advertisement


Ads help me to help you! Thanks!

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


  Show related articles:


  Comment Form

Click here to open the form


  0 Comments

No comments yet...

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

Advertisement


Ads help me to help you! Thanks!

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

Advertisement


Ads help me to help you! Thanks!

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