-1

i am using partials to decorate Zend_Navigation to fetch desired output. everything is working good except i am having difficulty adding class="active" in <a href..> tag. here is my layout partial sidebar.phtml

<ul id="menu" class="nav">
<?php foreach($this->container as $page): ?>
    <li class="<?php echo $page->class; ?>"><a href="<?php echo $page->getHref(); ?>"><span><?php echo $page->label; ?></span></a></li>
<?php endforeach; ?>
</ul>

in the <a href="<?php echo $page->getHref(); ?>"> i want to add class="active" for the current page.

i tried some solutions which i found after searching. but nothing worked for me.

most of the solutions talk about doing it in controller for example

$page = $this->view->navigation()->findOneByLabel('Your Label');
if ( $page ) {
  $page->setActive();
}

i haven't tested this yet. as i am using multiple navigations in the layout from one single navigation.xml file. i was wondering if is there a way i could do it in partials itself instead of in controllers or other helpers?

thank you

Ibrahim Azhar Armar
  • 25,288
  • 35
  • 131
  • 207
  • i don't need an active class in li tag. – Ibrahim Azhar Armar Apr 11 '12 at 14:41