max submenu items

For discussion and questions related to CMS Specific templates and stylesheets (CSS), and themes. or layout issues. This is not a place for generic "I don't know CSS issues"
Post Reply
sandertimmermans
New Member
New Member
Posts: 2
Joined: Wed Dec 28, 2011 6:35 pm

max submenu items

Post by sandertimmermans »

Hi,

Can anyone help me with my following problem:

I've created a site with 2 vertical divs. div1 for the main menu and div2 for the submenu.
The height of the divs are fixed. So if i create several subitems (projects in this case), the list is getting to large. Is there a way to set a maximum of submenu items? I want to create a link at the bottom of div2 to link to page 2.

Kind regards,

Sander
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: max submenu items

Post by Dr.CSS »

There is no way to tell menus to only show X amount of items...
sandertimmermans
New Member
New Member
Posts: 2
Joined: Wed Dec 28, 2011 6:35 pm

Re: max submenu items

Post by sandertimmermans »

Hi Dr.Css,

Is there another way to fix my problem?

Kind regards,

Sander
Wishbone
Power Poster
Power Poster
Posts: 1368
Joined: Tue Dec 23, 2008 8:39 pm

Re: max submenu items

Post by Wishbone »

I'm assuming that you are using two different {menu} calls.. One for the main menu, and another for the submenu.

if so, you could put a counter in your menu template and have it stop after a certain number is reached.

Assuming your submenu (maybe in a sidebar?) is being called like:

{menu childrenof=$page_alias number_of_levels=1}
(or start_level=2 instead of the childrenof parameter)

you can modify your template like:

Code: Select all

{assign var=count value=0}
{foreach .....}
{if $count<5}
:
:
{* rest of template inside the foreach loop *}
:
:
{/if}
{assign var=count value=$count+1}
{/foreach}
In the example above, it clears out a counter, and increments it for each menu item shown. Once it hits 5 (or whatever), the remaining items stops being processed.

If you have sub-sub menu items being displayed (no number_of_levels parameter), then the count will be skewed, since it's also counting the sub-sub menu items.. You would have to keep track of the depth before incrementing the counter.
Post Reply

Return to “Layout and Design (CSS & HTML)”