Here's a UDT I call get_root_alias.
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
use it like this: {get_root_alias alias=$page_alias assign='root_alias'}
*/
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;
}
Next, getting the title of a page, given a page alias should be as simple as a UDT like this:
Code: Select all
/* get the page title of any page, given an alias
* call it like this: {get_page_title alias=$root_alias}
*/
if( !isset($params['alias']) ) return;
global $gCms;
$contentops =& $gCms->GetContentOperations();
$contentobj = $contentops->LoadContentFromAlias( $params['alias'] );
$title = $contentobj->Name();
if( isset( $params['assign'] ) )
{
$smarty =& $gCms->GetSmarty();
$smarty->assign($params['assign'],$title);
return;
}
return $title;
So in total, to get the title of the top level parent:
Code: Select all
{get_root_alias alieas=$page_alias assign='root_alias'}{get_page_title alias=$root_alias}
Now, this second tag is untested, but it should be pretty close.