Thursday 23 June 2005 7:49:28 pm
I have a two level navigation bar that has to change from 1 level to 2 level depending on what section of the site a visitor is currently in, for example, if a visitor is on the homepage the navigation consists of only the top level, but if they are on any other page the navigation will consist of both the top level nav and a second level nav. My current pagelayout.tpl contains the following code:-
{* Loop through the top level navigation and output it. *}
{let mainMenu=treemenu( $module_result.path,
$module_result.node_id,
array('folder'), 0, 1 )}
<div id="main-nav">
<div class="retainer">
<ul>
{* Here is the loop, class indexed by node_ID number. *}
{section var=menu loop=$mainMenu}
<li class="node-{$menu.id}"><a href={$menu.item.url_alias|wash|ezurl}>{$menu.item.text|wash}</a></li>
{/section}
</ul>
</div>
</div>
{/let}
{* Check if we need the sub-nav *}
{let subNav='yes'}
{section show=$subNav|eq('yes') }
{* If we are in the right section loop through the second level navigation and output it. *}
{let subMenu=treemenu($module_result.path,
$module_result.node_id,
array('folder'), 1, 1 )}
<div id="sub-nav">
<div class="retainer">
<ul>
{* Here is the loop, class indexed by ID number. *}
{section var=menu loop=$subMenu}
<li class="node-{$menu.id}"><a href={$menu.item.url_alias|wash|ezurl}>{$menu.item.text|wash}</a></li>
{/section}
</ul>
</div>
</div>
{/let}
{* If we are not in the right section ignore the sub-nav and replace it with nothing *}
{section-else}
{/section}
{/let}
The reason i need to remove the sub-nav if it's not needed in due to the fact that i need to get rid of any redundant HTML code (particularly the empty <ul> tags for validation reasons). My problem is I am unsure as to the syntax of the following.
From the Documentation:-
>How do I access the section id in pagelayout.tpl?
>One way is via $DesignKeys:used.section.
>$DesignKeys is a way to know the section you are actually in. >In order to retrieve a section assigned to a current content object you can use let sectionID=first_set($node.object.section_id,0). Obviousley looking at my code above you will notice i have setup my condition as follows:-
{let subNav='yes'}
{section show=$subNav|eq('yes') }
*some html etc.*
{section-else}
*some html etc.*
{/section}
{/let}
My question is how can I use the code from the documentation within the code above to make this work? Any help is much appreciated.
Pardon me while I burst into flames...
|