[cmsms-dev] Suggested additions to the recently_updated tag
Kent Olsson
olsson.kent at comhem.se
Thu Jan 10 05:28:04 CST 2008
I have made some additions to the recently_updated tag
When number = 1 (it is no list anymore) the link to the page changed has
been removed and a new parameter called showlink is false, then it
works. It also checks when the current page, where the tag has been put,
has been updated.
Very practical to put at each page.
---------------------------
<?php
#CMS - CMS Made Simple
#(c)2004 by Ted Kulp (wishy at users.sf.net)
#This project's homepage is: http://cmsmadesimple.sf.net
#
# 2008 Additions by Kent Olsson
#
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
function smarty_cms_function_recently_updated($params, &$smarty)
{
if(empty($params['number']))
{
$number = 10;
}
else
{
$number = $params['number'];
}
if(empty($params['leadin']))
{
$leadin = "Modified: ";
}
else
{
$leadin = $params['leadin'];
}
if(empty($params['showlink']) || $number > 1)
{
$showlink='true';
}
else
{
$showlink = $params['showlink'];
}
if(empty($params['showtitle']))
{
$showtitle='true';
}
else
{
$showtitle = $params['showtitle'];
}
$dateformat = isset($params['dateformat']) ?
$params['dateformat'] : "d.m.y h:m" ;
$css_class = isset($params['css_class']) ?
$params['css_class'] : "" ;
if (isset($params['css_class'])){
$output = '<div class="'.$css_class.'"><ul>';
}
else {
$output = '<ul>';
}
global $gCms;
$hm =& $gCms->GetHierarchyManager();
$db = &$gCms->db;
// Get list of most recently updated pages excluding the home page
if($number == 1)
{
$thispage = $gCms->variables['page'];
$q = "SELECT * FROM ".cms_db_prefix()."content WHERE (content_id=" .
$thispage . " AND type='content' OR type='link')
AND default_content != 1 AND active = 1
ORDER BY modified_date DESC LIMIT ".((int)$number);
}
else
{
$q = "SELECT * FROM ".cms_db_prefix()."content WHERE (type='content'
OR type='link')
AND default_content != 1 AND active = 1
ORDER BY modified_date DESC LIMIT ".((int)$number);
}
$dbresult = $db->Execute( $q );
if( !$dbresult )
{
echo 'DB error: '. $db->ErrorMsg()."<br/>";
}
while ($dbresult && $updated_page = $dbresult->FetchRow())
{
$curnode =& $hm->getNodeById($updated_page['content_id']);
$curcontent =& $curnode->GetContent();
$output .= '<li>';
if($showlink == 'true')
{
$output .= '<a
href="'.$curcontent->GetURL().'">'.$updated_page['content_name'].'</a>';
if ((FALSE == empty($updated_page['titleattribute'])) &&
($showtitle=='true'))
{
$output .= '<br />';
}
}
if ((FALSE == empty($updated_page['titleattribute'])) &&
($showtitle=='true'))
{
$output .= $updated_page['titleattribute'];
}
if($number > 1)
{
$output .= '<br />';
}
$output .= $leadin;
$output .=
date($dateformat,strtotime($updated_page['modified_date']));
$output .= '</li>';
}
More information about the cmsms-dev
mailing list