Page 1 of 1

[solved] Collapsing menus - howto?

Posted: Wed Oct 10, 2007 11:33 am
by sturla69
Hi

Check out this link: http://utvikling.newelement.no/profilforum/index.php?page=gaver

I'm trying to get the vertical menu on the left side to stay "closed" until clicked. It should do nothing on mouseover. When clicked, the submenu-items should show, and stay open until another "top-menu" selection in the left menu has been clicked. Tried the "collapse='1/0' but does nothing useful. Tried the "section_expand" variant which is found in documentation of the Menu Manager, but can't get this to work the way I want it to...

I'm guessing there is a simple solution to this, but I'm just not seeing it... So if anyone can help, thank you very much...

Menucode:

Code: Select all

{* CSS classes used in this template:
#menuwrapper - The id for the <div> that the menu is wrapped in. Sets the width, background etc. for the menu.
#primary-nav - The id for the <ul>
.menuparent - The class for each <li> that has children.
.menuactive - The class for each <li> that is active or is a parent (on any level) of a child that is active. *}
{if $count > 0}
<div id="menuwrapper_vert">
<ul id="primary-nav_vert">
{foreach from=$nodelist item=node}
{if $node->depth > $node->prevdepth}

	{repeat string="<ul>" times=$node->depth-$node->prevdepth}
{elseif $node->depth < $node->prevdepth}

	{repeat string="</li></ul>" times=$node->prevdepth-$node->depth}
	</li>
{elseif $node->index > 0}</li>
{/if}
{if $node->parent == true or ($node->current == true and $node->haschildren == true)}
	<li class="menuactive menuparent"><a class="menuactive menuparent" 
{elseif $node->current == true}
	<li class="menuactive"><a class="menuactive" 
{elseif $node->haschildren == true}
	<li class="menuparent"><a class="menuparent" 
{elseif $node->type == 'sectionheader'}
        <li class="sectionheader"><span> {$node->menutext} </span>
{elseif $node->type == 'separator'}
        <li style="list-style-type: none;"> <hr class="separator" />
{else}
	<li><a 
{/if}
{if $node->type != 'sectionheader' and $node->type != 'separator'}
href="{$node->url}" {if $node->accesskey != ''}accesskey="{$node->accesskey}" {/if}{if $node->tabindex != ''}tabindex="{$node->tabindex}" {/if}{if $node->titleattribute != ''}title="{$node->titleattribute}"{/if}{if $node->target ne ""} target="{$node->target}"{/if}><dfn>{$node->hierarchy}: </dfn>{$node->menutext}</a>
{elseif $node->type == 'sectionheader'}
><dfn>{$node->hierarchy}: </dfn>{$node->menutext}</a>
{/if}

{/foreach}

	{repeat string="</li></ul>" times=$node->depth-1}		</li>
	</ul>
<div class="clearb"></div>
</div>
{/if}
Code for implementing in template:

Code: Select all

{menu template='PF_Sidemeny' start_level='3' number_of_levels='4' collapse='0'}
Styles:

Code: Select all

/* Horizontal menu for the CMS CSS Menu Module */
/* by Alexander Endresen */

#menu_vert_top {
   margin-left: 0px;
   margin-right: 1px;
}

/* The wrapper clears the floating elements of the menu */

/* Fix for Opera 8 */
.clearb { clear: both; }
#menuwrapper { 
   /* Fix for Opera 8 */ 
   /*   overflow: hidden;  */ 
   background: transparent url(uploads/images/design/bg_menu.jpg) 0 0 no-repeat;
   /* border-bottom: 1px solid #C0C0C0; */
   width: 881px;
}

/* Set the width of the menu elements at second level. Leaving first level flexible. */
#primary-nav li li { 
   width: 200px; 
}


/* Unless you know what you do, do not touch this */ 
#primary-nav, #primary-nav ul { 
   list-style: none; 
   margin: 0px; 
   padding: 0px; 
}
#primary-nav ul { 
   position: absolute; 
   top: auto; 
   display: none; 
}
#primary-nav ul ul { 
   margin-top: 1px;
   margin-left: -1px;
   left: 100%; 
   top: 0px; 
}
	
#primary-nav li { 
   margin-left: -1px;
   float: left; 
}
#primary-nav li li { 
   margin-left: 0px;
   margin-top: -1px;
   float: none; 
   position: relative; 
}

/* Styling the basic apperance of the menu elements */
#primary-nav a { 
   display: block; 
   margin: 0px; 
   padding: 5px 10px; 
   text-decoration: none; 
   color: #000000;
   font-weight: bold;
}
#primary-nav li a { 
   border-right: 1px solid #C0C0C0;
   /* border-left: 1px solid #C0C0C0; */
}
#primary-nav li a:hover { 
   border-right: 1px solid #C0C0C0;
   background-color: #95bf40;
   color: #FFFFFF;
   /* border-left: 1px solid #C0C0C0; */
}
#primary-nav li li a { 
   /* border: 1px solid #C0C0C0; */
}	
#primary-nav li, #primary-nav li.menuparent { 
   background-color: transparent; 
}

/* Styling the basic apperance of the active page elements (shows what page in the menu is being displayed) */

#primary-nav li.menuactive { 
   background-color: #95bf40; 
}


/* Styling the basic apperance of the menuparents - here styled the same on hover (fixes IE bug) */
#primary-nav ul li.menuparent, 
#primary-nav ul li.menuparent:hover, 
#primary-nav ul li.menuparenth { 
/* arrow for menuparents */
   /*background-image: url(images/cms/arrow.gif);*/ 
   background-position: center right; 
   background-repeat: no-repeat; 
}


/* Styling the apperance of menu items on hover */

#primary-nav li:hover, 
#primary-nav li.menuh, 
#primary-nav li.menuparenth, 
#primary-nav li.menuactiveh { 
   background-color: transparent; 
}


/* The magic - set to work for up to a 3 level menu, but can be increased unlimited */

/* 
just add 
#primary-nav li:hover ul ul, 
#primary-nav li.menuparenth ul ul ul,
for fourth level 
*/
#primary-nav ul, 
#primary-nav li:hover ul, 
#primary-nav li:hover ul ul, 
#primary-nav li.menuparenth ul, 
#primary-nav li.menuparenth ul ul { 
   display: none; 
}

/* add 
#primary-nav ul ul ul li:hover ul, 
#primary-nav ul ul ul li.menuparenth ul,
for fourth level
*/
#primary-nav li:hover ul, 
#primary-nav ul li:hover ul, 
#primary-nav ul ul li:hover ul, 
#primary-nav li.menuparenth ul, 
#primary-nav ul li.menuparenth ul, 
#primary-nav ul ul li.menuparenth ul { 
   display: block; 
}


/* IE Hacks */
#primary-nav li li { 
   float: left; 
   clear: both; 
}
#primary-nav li li a { 
   height: 1%; 
}

Re: Collapsing menus - howto?

Posted: Wed Oct 10, 2007 10:23 pm
by Dr.CSS
I believe you will find an expanding/collapse menu here...

http://wiki.cmsmadesimple.org/index.php ... nu_Manager

Re: Collapsing menus - howto?

Posted: Thu Oct 11, 2007 5:22 am
by sturla69
As I mentioned in my post, I've tried the section expand menu found on the page mentioned in the above post... It won't do what it's supposed to as soon as I apply my css id's and classes... But thanks for the tip Mark!

To clarify, the menu mentioned in the example requires Section Headers, which I can't use. Every menu item needs to be Content....

Any other tips are greatly appreciated!

[SOLVED] Re: Collapsing menus - howto?

Posted: Thu Oct 11, 2007 5:59 am
by sturla69
This was a pretty obvious solution... Using the primary-nav ID for the meny, just changed display: none; to display: block; in the appropriate css styles, added collapse='1' to the menu item in the template, and swoosh! It works like I want it to.

Code: Select all

#primary-nav_vert li:hover ul, 
#primary-nav_vert ul li:hover ul, 
#primary-nav_vert ul ul li:hover ul, 
#primary-nav_vert li.menuparenth ul, 
#primary-nav_vert ul li.menuparenth ul, 
#primary-nav_vert ul ul li.menuparenth ul { 
   background-color: #FFFFFF;
/*   background-color: #95bf40;*/
   display: block; /* This used to be: display: none; */
   z-index: 100;
And in the template:

Code: Select all

{menu template='PF_Sidemeny' start_level='3' number_of_levels='4' collapse='1'}
Thanks for any contributions!!

Re: [solved] Collapsing menus - howto?

Posted: Thu Oct 11, 2007 6:07 am
by Dr.CSS
That's not what I thought you were looking for, it acts just like a default template menu... top main menu with vertical side menu...

Re: [solved] Collapsing menus - howto?

Posted: Thu Oct 11, 2007 6:11 am
by sturla69
Sorry for the confusing post/bad explanation... Glad you contribute anyhow, you're contributions to the forum are invalueable. Thanks man!