Page 1 of 1

[Solved] Menu manager

Posted: Tue Jan 06, 2009 9:22 am
by christiaans
Hey guys,

I am - for a new, quite big project I am working on - running into an issue with the menu manager.

First of all, I am using CMSMS 1.5.1, together with the latest Menu Manager.

Now, the thing I'd like to achieve is to show the main menu and sub pages on a different line. No problem, works great. However, I want to show a certain line of text (something like: "There are no subpages for this page") when there are no subpages. At that point I am running into an issue;

I am calling my submenu with the following smarty:
{menu template="sub-nav" start_level="2" number_of_levels="1"}
And I have the following template for my sub menu:
{if $count > 0}



{foreach from=$nodelist item=node}

{if $node->current == true}
url}" class="current"{if $node->target ne ""} target="{$node->target}"{/if}>{$node->menutext}

{else}
url}" {if $node->target ne ""} target="{$node->target}"{/if}>{$node->menutext}
{/if}

{/foreach}



{else}


There are no pages to display here (just sample text!)


{/if}
However, the $count variable is not functioning (if I render it in the menu, it doesn't display anything), and therefore the line does not show up.

Does anyone know another way around (I hate it when I have to work with "{if $node->depth == 2}" and so on.. or how to fix this??

Any help would be greatly appreciated!  :)

Re: Menu manager

Posted: Tue Jan 06, 2009 10:24 am
by christiaans
Okay, so I found a way to fix it, awesome :)!

First I noticed that if there are no pages on the second level, the menu tag does not output anything, which gave me an idea.

What I did was the following:
{capture assign="submenu"}{menu template="subnav" start_level="2"}{/capture}

{if $submenu == ""}

There is no subpage to display.


{else}
{$submenu}
{/if}
What this does (it's quite obvious, but for those who are not so experienced :)), is check if the {menu} tag puts out anything, and if it does not, it displays the line "There is no subpage to display", however, if it does output something, then it will render the menu. Works like a charm!

I am glad it worked out this way, and it may be useful for others as well :).

Re: [Solved] Menu manager

Posted: Mon May 25, 2009 3:58 pm
by joecannes
Nice! I have been looking for something like this as well. The only difference for me is, I would place an empty div to add some height to the page, as my sub nav shows up in a left hand column.

One question, I looked under Extensions > Tags, and dd not find the {capture} tag.
Where does that come from and what does it do?


Thanks,

Joe C.

Re: [Solved] Menu manager

Posted: Wed Jul 22, 2009 2:32 am
by Dr.CSS
{capture} is smarty not a tag...