Abusing MenuManger for layout

General project discussion. NOT for help questions.
Post Reply
nils73
Power Poster
Power Poster
Posts: 520
Joined: Wed Sep 08, 2004 3:32 pm

Abusing MenuManger for layout

Post by nils73 »

While working on the WFD-Website (see forum for more details) we wanted to create a changing header-image based on CSS without having different templates for each category. So what we did is use the MenuManger and define a new template which we called "getSection" and which uses the following code:

Code: Select all


{foreach from=$nodelist item=node}
  {if $node->current == true}{$node->hierarchy|truncate:1:""}{/if}
{/foreach}

Then we called it inside each template (we have three templates) by using the following code:

Code: Select all


<div id="header" class="style0{cms_module module='menumanager' template='getSection'}">

But now we have a slight problem with a different project where we have hidden some navigation-items (don't show in navigation set in page-settings) but where we need a different header-graphic when the page is loaded. What happens now is that we get

Code: Select all


<div id="header" class="style0">

because the page is not a menu-element. Any other ideas how to manage this? Might be useful for sitemaps as well where I see the same problem.

Regards,
Nils
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

Re: Abusing MenuManger for layout

Post by tsw »

menu manager is kinda heavy for that kind of information, have you looked here

http://wiki.cmsmadesimple.org/index.php ... re#else_if

http://wiki.cmsmadesimple.org/index.php ... .27s_alias
nils73
Power Poster
Power Poster
Posts: 520
Joined: Wed Sep 08, 2004 3:32 pm

Re: Abusing MenuManger for layout

Post by nils73 »

Thanks man ... now THAT was fast ... found get_root_page_alias and modified it as follows

get_root_page_hierarchy

Code: Select all


global $gCms;
global $smarty;

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

$var = 'root_page_id';
if( isset($params['assign']) && $params['assign'] != '' )
{
  $var = $params['assign'];
}
$result = "NO RESULT";
$thisPage = $gCms->variables['content_id'];
$currentNode = &$manager->sureGetNodeById($thisPage);
while( isset($currentNode) && $currentNode->getLevel() >= 0 )
{
    $currentContent =& $currentNode->getContent();
    $result = $currentContent->Hierarchy();
    $currentNode =& $currentNode->getParentNode();
}
$smarty->assign($var,$result);

I love CMSMS and I love this great community. You made my day.

Thanx.
Nils
nils73
Power Poster
Power Poster
Posts: 520
Joined: Wed Sep 08, 2004 3:32 pm

Re: Abusing MenuManger for layout

Post by nils73 »

It's now in the Wiki.

Regards,
Nils
tsw
Power Poster
Power Poster
Posts: 1408
Joined: Tue Dec 13, 2005 10:50 pm

Re: Abusing MenuManger for layout

Post by tsw »

great, thanks for the wiki contribution
Post Reply

Return to “General Discussion”