[Solved] Menu manager

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
christiaans
Power Poster
Power Poster
Posts: 300
Joined: Tue Mar 04, 2008 10:37 am

[Solved] Menu manager

Post 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!  :)
Last edited by christiaans on Tue Jan 06, 2009 10:24 am, edited 1 time in total.
christiaans
Power Poster
Power Poster
Posts: 300
Joined: Tue Mar 04, 2008 10:37 am

Re: Menu manager

Post 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 :).
Last edited by christiaans on Thu Jan 08, 2009 12:23 pm, edited 1 time in total.
joecannes
Forum Members
Forum Members
Posts: 93
Joined: Mon Nov 26, 2007 5:00 pm
Location: Montreal, Quebec

Re: [Solved] Menu manager

Post 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.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12709
Joined: Thu Mar 09, 2006 5:32 am
Location: Arizona

Re: [Solved] Menu manager

Post by Dr.CSS »

{capture} is smarty not a tag...
Post Reply

Return to “Modules/Add-Ons”