[SOLVED] menumanager: display parent's menutext above subnavigation

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.
Post Reply
User avatar
lollipop27
Forum Members
Forum Members
Posts: 237
Joined: Wed Sep 12, 2007 4:09 pm

[SOLVED] menumanager: display parent's menutext above subnavigation

Post by lollipop27 »

hi there,

it seems to me that there is no $node attribute that helps me with that...


i want to display the parent's node's menutext above the subnavigation...


here the structure of main navigation

AA  BB  CC  DD      (green = active)

and the subnavi should be like that (children of the active main navigation)

CC:

CC_1
CC_2
CC_3


my code is like that:

Code: Select all

{* CSS classes used in this template:
.activeparent - The top level parent when a child is the active/current page
li.active0n h3 - n is the depth/level of the node. To style the active page for each level separately. The active page is not clickable.
.clearfix - Used for the unclickable h3 to use the entire width of the li, just like the anchors. See the Tools stylesheet in the default CMSMS installation.
li.sectionheader h3 - To style section header
li.separator - To style the ruler for the separator *} 

{if $count > 0}

{*Here is my text with the parent menutext..*}
<p class="txtueber">360° {$node->parent->menutext}</p>

<ul>
{foreach from=$nodelist item=node}
{if $node->depth > $node->prevdepth}
{repeat string="<ul>" times=$node->depth-$node->prevdepth}
{elseif $node->depth < $node->prevdepth}
{repeat string="</li></ul>" times=$node->prevdepth-$node->depth}
</li>
{elseif $node->index > 0}</li>
{/if}

{if $node->current == true}
<li class="currentpage"><h3>{$node->menutext}</h3>

{elseif $node->parent == true}
<li class="activeparent"><a class="activeparent" href="{$node->url}"{if $node->accesskey != ''} accesskey="{$node->accesskey}"{/if}{if $node->tabindex != ''} tabindex="{$node->tabindex}"{/if}{if $node->titleattribute != ''} title="{$node->titleattribute}"{/if}>{$node->menutext}</a>

{elseif $node->type == 'sectionheader'}
<li class="sectionheader">{$node->menutext}

{elseif $node->type == 'separator'}
<li class="separator" style="list-style-type: none;"> <hr />

{else}
<li><a href="{$node->url}"{if $node->accesskey != ''} accesskey="{$node->accesskey}"{/if}{if $node->tabindex != ''} tabindex="{$node->tabindex}"{/if}{if $node->titleattribute != ''} title="{$node->titleattribute}"{/if}{if $node->target != ''} target="{$node->target}"{/if}>{$node->menutext}</a>

{/if}

{/foreach}
{repeat string="</li></ul>" times=$node->depth-1}</li>
</ul>
{/if}

the page is http://wp1057983.wp090.webpack.hosteuro ... ifferences

behind the 360° on the right hand side should be "Unterschiede"
Last edited by lollipop27 on Wed Nov 07, 2007 1:50 am, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: menumanager: display parent's menutext above subnavigation

Post by Dr.CSS »

Have you tried...

{$node->parent->$node->menutext}
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: menumanager: display parent's menutext above subnavigation

Post by calguy1000 »

if you see this topic

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

it will give you an idea of how to create a UDT to get the menu text of a page given a page alias, also there is a way of finding out the page alias of the parent of a page given an alies.....

UDT's can be embedded in your page template, or can be embedded in your menu template.
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.
User avatar
lollipop27
Forum Members
Forum Members
Posts: 237
Joined: Wed Sep 12, 2007 4:09 pm

Re: menumanager: display parent's menutext above subnavigation

Post by lollipop27 »

thanks so far, calguy1000, but it's not exactly what I want....
The nevigation you can see on top is the 3rd level and the navigation at the right is the 4th level.... but your code gives me the 1st level..... ("Deutsch")
So, how can I get this script to stop at the 3rd level??
Becuase I want it always, not metter if I klick the 3rd level or the 4th level, to display the active third level....

sorry my PHP is miserable.... so I cant change it by myself..... I understand the script... but How can I change the while id!=-1 to while hierachy is >= 3.... or something like that....  ???

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;
}
User avatar
lollipop27
Forum Members
Forum Members
Posts: 237
Joined: Wed Sep 12, 2007 4:09 pm

Re: menumanager: display parent's menutext above subnavigation

Post by lollipop27 »

@ mark... this gives me an error..... would have been soooo easy
User avatar
lollipop27
Forum Members
Forum Members
Posts: 237
Joined: Wed Sep 12, 2007 4:09 pm

Re: menumanager: display parent's menutext above subnavigation

Post by lollipop27 »

thanks to calguy1000 i have the SOLUTION!!!! :) :) :)

this is the menumanager side navigation now....

Code: Select all

{* CSS classes used in this template:
.activeparent - The top level parent when a child is the active/current page
li.active0n h3 - n is the depth/level of the node. To style the active page for each level separately. The active page is not clickable.
.clearfix - Used for the unclickable h3 to use the entire width of the li, just like the anchors. See the Tools stylesheet in the default CMSMS installation.
li.sectionheader h3 - To style section header
li.separator - To style the ruler for the separator *} 

{if $count > 0}
<p class="txtueber">360° 
{get_page_depth assign='depth'}
{if $depth == 3}
  {get_page_menutext assign='menutext'}
{else}
  {get_parent_page_alias assign='parentalias'}{get_page_menutext page=$parentalias assign='menutext'}
{/if}
{$menutext}</p>

<ul>
{foreach from=$nodelist item=node}
{if $node->depth > $node->prevdepth}
{repeat string="<ul>" times=$node->depth-$node->prevdepth}
{elseif $node->depth < $node->prevdepth}
{repeat string="</li></ul>" times=$node->prevdepth-$node->depth}
</li>
{elseif $node->index > 0}</li>
{/if}

{if $node->current == true}
<li class="currentpage"><h3>{$node->menutext}</h3>

{elseif $node->parent == true}
<li class="activeparent"><a class="activeparent" href="{$node->url}"{if $node->accesskey != ''} accesskey="{$node->accesskey}"{/if}{if $node->tabindex != ''} tabindex="{$node->tabindex}"{/if}{if $node->titleattribute != ''} title="{$node->titleattribute}"{/if}>{$node->menutext}</a>

{elseif $node->type == 'sectionheader'}
<li class="sectionheader">{$node->menutext}

{elseif $node->type == 'separator'}
<li class="separator" style="list-style-type: none;"> <hr />

{else}
<li><a href="{$node->url}"{if $node->accesskey != ''} accesskey="{$node->accesskey}"{/if}{if $node->tabindex != ''} tabindex="{$node->tabindex}"{/if}{if $node->titleattribute != ''} title="{$node->titleattribute}"{/if}{if $node->target != ''} target="{$node->target}"{/if}>{$node->menutext}</a>

{/if}

{/foreach}
{repeat string="</li></ul>" times=$node->depth-1}</li>
</ul>
{/if}

this is the UDT "get_page_depth"

Code: Select all

global $gCms;
global $smarty;

$manager =& $gCms->GetHierarchyManager();

if( isset($params['assign']) && $params['assign'] != '' )
{
  $var = $params['assign'];
}

$thisPage = $gCms->variables['content_id'];
$currentNode = &$manager->sureGetNodeById($thisPage);
$result = $currentNode->getLevel() + 1;
if( isset($params['assign']) && $params['assign'] != '' )
{
  $var = $params['assign'];
  $smarty->assign($var,$result);
}
else
{
  return $result;
}


this is the UDT "get_parent_page_alias"

Code: Select all

    global $gCms;
    $contentops =& $gCms->GetContentOperations();
    $smarty =& $gCms->GetSmarty();

    if( isset($params['page']) )
    {
        $alias = $params['page'];
    }
    else 
      {
	$alias = $smarty->get_template_vars('page_alias');
      }
    $content =& $contentops->LoadContentFromAlias($alias);
    if( !is_object($content) ) return '';

    $parentid = $content->ParentId();
    if( $parentid != 0 ) 
     {
        $alias = $contentops->GetPageAliasFromId($parentid);
     }
   else
     {
        $alias = '';
     }

   if( isset($params['assign']) )
    {
       $smarty->assign($params['assign'],$alias);
    }
   else
    {
       return $alias;
   }


this is the UDT "get_page_menutext"

Code: Select all

    global $gCms;
    $contentops =& $gCms->GetContentOperations();
    $smarty =& $gCms->GetSmarty();

    if( isset($params['page']) )
    {
        $alias = $params['page'];
    }
    else 
      {
	$alias = $smarty->get_template_vars('page_alias');
      }

    $content =& $contentops->LoadContentFromAlias($alias);
    if( !is_object($content) ) return '';

   $text = $content->MenuText();

   if( isset($params['assign']) )
    {
       $smarty->assign($params['assign'],$text);
    }
  else
   {
      return $text;
   }


and then the wonderful thing worked! GREAT!!!
Post Reply

Return to “CMSMS Core”