Page 1 of 1

[SOLVED] Parent Title TAG see my last comment

Posted: Wed Nov 07, 2007 5:32 pm
by howey
I have been searching the forum for an answer to enable me to display the parent page title/menu text on a child page.

I have found several threads that look as if they would help. But as I am a designer and not a programmer and a noobie to CMSMS I can't figure out what to do with the code.

I tied cut and pasting the code from here http://forum.cmsmadesimple.org/index.ph ... 778.0.html int a document "function.parent_title.php" and putting that into the plugins folder but it didn't work.

Another thread outlined code for a UDT? http://forum.cmsmadesimple.org/index.ph ... 733.0.html. But I still don't know how to use the code – where to put it or install it.

The site I am building is using the simple_navigation.tpl, which works for all the other navigation menus.

You can view a test page here if it helps: http://www.idaserver.co.uk/ibc/index.ph ... who-we-are. Although I am a bit worried that I will be flamed for the quality of my code – I have used tables and it may be a bit clumsy and isn't any where near strict xml.
:'(

Re: Parent Title TAG

Posted: Wed Nov 07, 2007 5:35 pm
by howey
Even the post just below me is a bit hard for me to follow

http://forum.cmsmadesimple.org/index.ph ... 630.0.html

Re: Parent Title TAG

Posted: Wed Nov 07, 2007 5:38 pm
by RonnyK
I used this one,

http://forum.cmsmadesimple.org/index.ph ... l#msg41774

Where the second part is the calling of the IDT, that gives you the variable back to use.

Ronny

Re: Parent Title TAG

Posted: Wed Nov 07, 2007 5:43 pm
by howey
The link you gave me referred to a strange

A strange "ERROR could not get module instance" in cmsms

Mmmm! confused.

Re: Parent Title TAG

Posted: Wed Nov 07, 2007 5:45 pm
by RonnyK
Sorry my mistake, had an older link in the clipboard.

http://forum.cmsmadesimple.org/index.ph ... l#msg53453

Ronny

Re: Parent Title TAG

Posted: Wed Nov 07, 2007 5:47 pm
by Dr.CSS
The link you gave...

First code goes in a new menu manager template...

Next three are User Defined Tags, UDT, that you will have to copy/paste into new ones on your site, naming them as they are called in the menu template...

Re: Parent Title TAG

Posted: Wed Nov 07, 2007 6:28 pm
by howey
I'm still not getting it  :-[

Is this the link you are referring to: http://forum.cmsmadesimple.org/index.ph ... 630.0.html

I am still confused.

Do I implement the UDT in the plugins directory and then call them in the new menu template and then the menu tag on the page?

Or do I define a new UDT and call it on the page template - which then refers to the new menu template that will replace the simple_navigation.tpl

Any clarification would help – I'll then go to bed and sleep on it.

Re: [SOLVED] Parent Title TAG see my last comment

Posted: Thu Nov 08, 2007 11:08 am
by howey
I get it now! Doh!

Thanks Mark

I slept on it came in afresh and the penny dropped. I cut and pasted the code from the link http://forum.cmsmadesimple.org/index.ph ... 778.0.html

Code: Select all

// This is only going to step up the tree one level

global $gCms;
$content_id = $gCms->variables['content_id'];
$hm =& $gCms->GetHierarchyManager();

$node =& $hm->getNodeById($content_id);

if ($node != null)
{

    //Grab the parent node
    $parentnode =& $node->getParentNode();
    $ncontent =& $node->getContent();
    $pnode = $ncontent->ParentID();

    //Make sure something came back
    if ($pnode != -1)
    {
        //Get the actual content object
        $content =& $parentnode->getContent();
    } 
    else {
        //Ok no parent lets get the title of this node
        $content = $ncontent;
     }

     if ($content != null) //Just in case
        {
            //Display it's title
            echo $content->Name();
        }   
}
and created a new UDT (user defined tag) in the CMSMS admin under user defined tags. Then I put the tag

Code: Select all

{parent_title} 
in the page template and it worked.