Page 1 of 1

Abusing MenuManger for layout

Posted: Thu Oct 12, 2006 10:17 am
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

Re: Abusing MenuManger for layout

Posted: Thu Oct 12, 2006 10:21 am
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

Re: Abusing MenuManger for layout

Posted: Thu Oct 12, 2006 10:47 am
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

Re: Abusing MenuManger for layout

Posted: Thu Oct 12, 2006 10:55 am
by nils73
It's now in the Wiki.

Regards,
Nils

Re: Abusing MenuManger for layout

Posted: Thu Oct 12, 2006 11:01 am
by tsw
great, thanks for the wiki contribution