[solved] how to get a title of the parent page?

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Locked
liudaz

[solved] how to get a title of the parent page?

Post by liudaz »

Hello,

I have been surfing the forum for some time to find the solution for my problem and i ended up in a dead end.

I am using the template "Top simple navigation + left subnavigation + 1 column". There is first level menu on the top, and second level submeniu in the sidebar.
1.About Us
1.1 Address
1.2 Phone
2. Who We Are
3. What We Do
If i press "address" or "phone" i still want to have a title (in this case it is "about us") above the subnavigation.
I believe modificationt of {breadrumbs} could do that, but too bad it doesnt have the "end-level" parameter. :(

I appresiate your help. :)

Liudas
Last edited by liudaz on Tue Sep 04, 2007 6:54 pm, edited 1 time in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: how to get a title of the parent page?

Post by calguy1000 »

Remind me on tuesday.  I have a UDT to get the page alias of the parent page.... You could use this, in conjunction with another UDT to get the page title of a page given the alias.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
liudaz

Re: how to get a title of the parent page?

Post by liudaz »

Will do so. Thank you in advance.  ;)
AmandaBTO
Forum Members
Forum Members
Posts: 51
Joined: Thu Aug 09, 2007 2:40 pm

Re: how to get a title of the parent page?

Post by AmandaBTO »

What great timing!  I could really use this too :)
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: how to get a title of the parent page?

Post by Dr.CSS »

Maybe this thread, found using search "title of parent page"...

http://forum.cmsmadesimple.org/index.ph ... 778.0.html
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: how to get a title of the parent page?

Post by calguy1000 »

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.
Last edited by calguy1000 on Tue Sep 04, 2007 3:51 pm, edited 1 time in total.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
AmandaBTO
Forum Members
Forum Members
Posts: 51
Joined: Thu Aug 09, 2007 2:40 pm

Re: how to get a title of the parent page?

Post by AmandaBTO »



Sweet assed!

liudaz

Re: how to get a title of the parent page?

Post by liudaz »

Works just like i wanted. Thank you very much! ;)
Locked

Return to “CMSMS Core”