Joomla 1.6 add "first" and "last" CSS classes to mod_menu


/ Published in: PHP
Save to your folder(s)

Copy /modules/mod_menu/tmpl/default.php to /templates/MYTEMPLATE/html/mod_menu/default.php


Copy this code and paste it in your HTML
  1. // Replace
  2. if ($item->deeper) {
  3. $class .= 'deeper ';
  4. }
  5.  
  6. // with this
  7. $currentitemcount ++;
  8. if ($item->shallower or $currentitemcount == count($list)) {
  9. $class .= 'last ';
  10. }
  11.  
  12. if ($lastdeeper or $currentitemcount == 1) {
  13. $class .= 'first ';
  14. }
  15.  
  16.  
  17. if ($item->deeper) {
  18. $class .= 'deeper ';
  19. $lastdeeper = true;
  20. } else {
  21. $lastdeeper = false;
  22. }

URL: http://forum.joomla.org/viewtopic.php?p=2459568#p2459568

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.