Code: Select all
/* Get the alias of the top level parent
Takes a page alias as input
outputs a page alias, or an empty string if the alias input is a top level
*/
if( !isset($params['alias']) ) return;
global $gCms;
$contentops =& $gCms->GetContentOperations();
$alias = '';
$id = $contentops->GetPageIDFromAlias( $params['alias'] );
while( $id != -1 )
{
$content =& $contentops->LoadContentFromId( $id );
if( is_object( $content ) ) {
$alias = $content->Alias();
$id = $content->ParentId();
}
}
if( isset($params['assign']) )
{
$smarty =& $gCms->GetSmarty();
$smarty->assign( $params['assign'], $alias );
return;
}
else
{
return $alias;
}