As you can read from the title, I'm trying to add class="current"
part to the HTML anchor tag that my zend_navigation renders.
Here's what i have:
Bootstrap.php
protected function _initNavigation(){
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$config = new Zend_Config_Xml(APPLICATION_PATH .'/configs/navigation.xml','nav');
$navigation = new Zend_Navigation($config);
$navigation->current()
$view->navigation($navigation);
}
And then in the View script:
<div class="NavMenu">
<?= $this->navigation()->menu(); ?>
</div>
I’m pretty sure there’s some standard and proper way of doing it, but after about couple hours of search, I’m unable to find my answer. Many thanks to you for your kind help.
Stick this in your controller...
public function init()
{
$uri = $this->_request->getPathInfo();
$activeNav = $this->view->navigation()->findByUri($uri);
$activeNav->active = true;
$activeNav->setClass("active");
}
For more information read the comments of the setClass method in Zend_Navigation_Page
http://framework.zend.com/svn/framework/standard/trunk/library/Zend/Navigation/Page.php