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!
Count days, is this page recent?
Previous article Next articleWith 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');
}
$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>
{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>
{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>
Comment Form
ReviewManager
ReviewManager
0 Comments
No comments yet...