Creating a submenu conditional
Posted: Wed Mar 06, 2013 7:49 pm
I have a main menu, and a sub menu. The submenu is called using:
so i ignore all level one menu items. The template code is as follows:
Now - I have one page that has no level 2 items, but in this instance I'd like to put a spacer div in. I've tried adding
at the bottom of my template, just before the {/if} statement. I expected the code to notice that $count == 0 and run my else statement, but this code isn't run at all.
It seems like if you call the menu with the start_level parameter then if $count == 0 then none of the code is run. Is there a way around this?
Code: Select all
{menu start_level="2" template="foresight_submenu"}
Code: Select all
{* Sub level navigation menu *}
{if $count > 0}
<ul class='sub_menu clearfix'>
{foreach from=$nodelist item=node}
{if $node->depth == 1}
{if $node->current == true or $node->parent == true}
<li class="active"><a href="{$node->url}">{$node->menutext}<span></span></a></li>
{else}
<li><a href="{$node->url}">{$node->menutext}<span></span></a></li>
{/if}
{/if}
{/foreach}
</ul>
{/if}
Code: Select all
{else}
<div class="spacer"></div>
at the bottom of my template, just before the {/if} statement. I expected the code to notice that $count == 0 and run my else statement, but this code isn't run at all.
It seems like if you call the menu with the start_level parameter then if $count == 0 then none of the code is run. Is there a way around this?