Home Snippets PHP Add menu link type css style to list in Joomla 2.5

Search PHP

    Login Form


    This modification is used when you want to add the css class entered in the link type options - link CSS Style to the <li>. The class will also be added to the <a>, this is default Joomla 2.5.

    It's done with an override of mod_menu/default.php. Copy the original file to your computer or if your template already uses an override, copy that override to your computer. An existing override is found in templates/<your template>/html/mod_menu named default.php.

    Search for the "foreach ($list as $i => &$item)" loop in your downloaded default.php. In the original file you can find it approx. at line 23. Make the modification as entered in the snippet code.

    Save your file and place it in templates/<your template>/html/mod_menu.
    If there is already an override, backup that one first before you place the new one.


    Snippet code:

    foreach ($list as $i => &$item) :
            //add a space and the extra css class to the li classes.
    	$class = 'item-'.$item->id.' '.$item->anchor_css;
            //end of modification
    	if ($item->id == $active_id) {
    		$class .= ' current';


    blog comments powered by Disqusblog comments powered by Disqus
    Joomla Templates by JoomlashackJoomla Templates by Joomlashack