Search code examples
phpframeworksjoomlajoomla-templatejmenu

Joomla menu css


I wanted to create a menu in the top of the page, because of the specific layout in the css i thought this is a solution to do this using the following code in my template (the index.php)

    $item_active = $menu->getActive();
    for($i = 0; $i >  count($menu_items); $i++){
        $item = $menu_items[$i];            
        if($item_active->id == $item->id)
            echo '<a href="'.$this->baseurl.'/'.$item->route.'"><div id="button_pressed"><div id="button_text">'.$item->title.'</div></div></a>';
        else
            echo '<a href="'.$this->baseurl.'/'.$item->route.'"><div id="button"><div id="button_text">'.$item->title.'</div></div></a>';

    }

But isnt there a better way, i think im missing a link here


Solution

  • This shouldn't be in your template. The menu should be in a module. Most menu modules have active highlighting built in. Even the core Joomla mod_menu supports active highlighting.