[eluser]awpti[/eluser]
Actually, I'm not building any sort of breadcrumb or multi-tiered menu.
Just trying to, literally, figure out how to more efficiently add 'class="current"' to the menu item based on the URI segment.
While your idea might fit within the realm of what I want to do, I simply can't fathom how. I took the simple approach, but definately not the right approach.
See below: (I'm not proud of this - and yes, it's a library.
EDIT:
figured it out!
Code:
class Otnmenu {
public $uri = '';
function build_menu()
{
$menu = array(
'/home' => 'Home',
'/blotter' => 'TechBlotter',
'/devblog' => 'DevBlog',
'/about' => 'About',
'/contact' => 'Contact'
);
foreach($menu as $key => $value)
{
$class = '';
if($uri === str_replace('/', '', $key))
{
$class = 'class="content" ';
}
$menu_final .= '<a '.$class.'href="'.$key.'/">'.$value."</a><br />\n";
}
return $menu_final;
}
}
In the controller:
Code:
$this->otnmenu->uri = $this->uri->segment(1);
$this->view->set('menu', $this->otnmenu->build_menu());