How To: Simple Dropdown with Joomla's Default Menu PDF Print E-mail
Written by Tim Gane   
Tuesday, 30 March 2010 11:56

Starting note: I haven't written for some time, over a month to be exact, and I haven't been motivated to lately. I decided early last week to make more of an effort, and now I find myself with a load more time, I will have no excuse to not write.

Recently, I was working on some issues on Eris's website and decided to make some changes to the menu system. Those changes were in hopes to make the site more cross browser compliant, and logically for the visitors to the site. Well doing some research, and testing with various solutions, I came across a wonderful way to create a simple drop down menu using the default menu module that comes with Joomla.

The example of the new drop down on Eris's website.


The advantages

Joomla's menu module will work with almost all SEF extensions, and even the default improvements, and this is important in the future for other extensions as well (for example, a new photo gallery). This will also decrease the worry that an update Joomla could potentially break your menu / module, as it is a core module provided with Joomla.


It is also more visually attractive to have the drop down, and offers more interactivity then a straight list of links. The technique is almost solely using CSS and limits the use of Javascript to a minimum. Infact, this doesn't use any addtional frameworks (such as jQuery or MooTools), and that is a positive for load time.


The Steps and Code

In the module, configure your settings to appear such as:

  1. Menu Style is set to List
  2. Always show sub-menu items is set to yes.
  3. Menu class suffix is set to san (you can pick your own, just make sure to make the changes in the JS and CSS.)

First insert into your CSS:


.menusan
{
 /* use these params to positions your menu */
 position: relative;
 left: 10px;
}
 
.menusan, .menusan li, .menusan li ul { /* all lists */
 padding: 0;
 margin: 0;
 list-style: none;
}
 
.menusan li a {
 display: block;
 width: 10em;
 color:#FFFFFF ;
 background-color:#BC031F;
 border:2px solid #BC031F;
 text-decoration:none;
}
 
.menusan li { /* all list items */
 float: left;
 width: 10em; /* width needed or else Opera goes nuts */
 border-bottom:1px solid #ccc;
}
 
.menusan li ul { /* second-level lists */
 position: absolute;
 width: 10em;
 left: -98%; /* using left instead of display to hide menus because display: none isn’t read by screen readers */
}
 
.menusan li a:hover {
 border:2px solid #8C7AD6;
 background-color:#8C7AD6;
 color:#fff;
}
 
.menusan li:hover ul, .menusan li.sfhover ul  { /* lists nested under hovered list items */
 left: auto; /* change is to 10px, 20px, etc for indenting the sub menue */
}

Insert the following javascript into the head of your templates index.php page:

sfHover = function()
{
 var sfEls = document.menusan.getElementsByTagName(”LI”);
 for (var j=0; j < sfEls.length; j++)
 {
  sfEls[j].onmouseover=function()
  {
   this.className+=” sfhover”;
  }
  sfEls[j].onmouseout=function()
  {
   this.className=this.className.replace(new RegExp(” sfhover\\b”), “”);
  }
 } 
}
if (window.attachEvent) window.attachEvent(”onload”, sfHover);

That's it, with that relative simple CSS / JS combo, you'll have a serviceable drop down that doesn't require a new module and take advantage of Joomla's core menu module.

Last Updated on Wednesday, 19 May 2010 06:54
 
Share This

Comments  

 
0 #7 2010-11-08 19:59
bzlzz nvxnd mgpxr urqfp dlreu
percocet: http://forums.mydigitallife.info/members/177008-Percocet got
hydrocodone: http://forums.mydigitallife.info/members/177010-Hydrocodone cdu
oxycodone: http://www.dontstayin.com/members/buy-oxycodone qtr
ritalin: http://rp.eliteskills.com/u.php?u=6733 bqr
cyclobenzaprine : http://rp.eliteskills.com/u.php?u=6734 tcp
ohsvvrb
Quote
 
 
0 #6 2010-10-13 00:53
gypoa bfefo cugcm vzkvm adhmd
adderall xr: http://s4.zetaboards.com/adderall/index/ qsa
xbdhgbgg
Quote
 
 
0 #5 2010-10-11 15:57
tox egb lfm dvi jnz
buy phendimetrazine : http://wiki.obgyn.net/account/Phendimetrazine cmmto
buy ephedra: http://wiki.obgyn.net/account/Ephedra rbdfg
dextroamphetami ne: http://wiki.obgyn.net/account/dextroamphetami ne gdfko
buy escitalopram oxalate: http://wiki.obgyn.net/account/Escitalopram bsuvg
buy buspirone: http://wiki.obgyn.net/account/Buspirone lbdnw
rxkzwco
Quote
 
 
0 #4 2010-10-04 11:10
nbstc hxvlw wiyzl zaizr zujaa
phentermine: http://intensedebate.com/people/Phentermine4 oex
vardenafil: http://gravatar.com/vardenafil4 ztq
tadalafil 20mg: http://gravatar.com/tadalafil4 pfm
sildenafil citrate: http://gravatar.com/sildenafil4 rjr
fvjlgvv
Quote
 
 
0 #3 2010-09-30 23:37
blz hta ymx few iwd
levitra rezeptfrei bestellen: http://pennanino.com xwggb
bhgcxgg
Quote
 
 
0 #2 2010-09-13 11:53
qcw ujy qdk oft ngs
buy accutane without a prescription: http://buyaccutane.blog.igg.com/ wyxcr
crizlul
Quote
 
 
0 #1 2010-07-30 12:20
hello, this my first post. dsfcsvcbyjyui
cxzc: http://google.com
http://sdfsd.com
Quote
 

Add comment


Security code
Refresh