Ritorna l'url di un item di un modulo (predefinito News) ma è estensibile.
Da testare che poi lo metto sul Wiki
Code: Select all
//
// UDT for link to News/Generic Module
// Alberto Benati (alby) <cms at xme.it>
//
// @param "id" - MANDATORY
// The article/module item ID
//
// @param "cntnt" - optional
// Form counter. It's not important for this example, but tomorrow...
//
// @param "origid" - optional
// The original page (default current page), can be an ID number or an alias.
//
// @param "redirect" - optional
// The redirect page (default current page), can be an ID number or an alias.
//
// @param "other" - optional
// Other query params.
//
// @param "assign" - optional
// Smarty assign variable.
//
// @example
// {module_link id=1 redirect='News'}
// {module_link id=1 module='Cataloger'} not implemented!
//
global $gCms;
global $smarty;
$id = 1;
if(isset($params['id']) && $params['id'] != '') $id = intval($params['id']);
$module = 'News';
if(isset($params['module']) && $params['module'] != '') $module = strtolower($params['module']);
$cntnt = '01';
if(isset($params['cntnt']) && $params['cntnt'] != '') $cntnt = $params['cntnt'];
$origid = $gCms->variables['content_id'];
if(isset($params['origid']) && $params['origid'] != '')
{
$manager =& $gCms->GetHierarchyManager();
$currentNode = &$manager->sureGetNodeById($params['origid']);
$currentContent =& $currentNode->getContent();
$origid = $currentContent->Id();
}
$redirect = $gCms->variables['content_id'];
if(isset($params['redirect']) && $params['redirect'] != '')
{
$manager =& $gCms->GetHierarchyManager();
$currentNode = &$manager->sureGetNodeById($params['redirect']);
$currentContent =& $currentNode->getContent();
$redirect = $currentContent->Id();
}
$other = '';
if(isset($params['other']) && $params['other'] != '') $other = $params['other'];
if(!empty($other)) $other = '&'.$other;
$url = $gCms->config['root_url']."/index.php?mact=";
switch($module)
{
default: $url .= "News,cntnt{$cntnt},detail,0&cntnt{$cntnt}articleid={$id}&cntnt{$cntnt}origid={$origid}&cntnt{$cntnt}returnid={$redirect}{$other}";
}
if(isset($params['assign']) && $params['assign'] != '')
{
$smarty->assign($params['assign'], $url);
return '';
}
else return $url;