4

Is it possible to add a CSS class to the inner pages within a Zend Navigation? I am trying to implement twitter bootstrap navigation dropdown

Thanks!

somejkuser
  • 8,856
  • 20
  • 64
  • 130

2 Answers2

3

I had the same requirement for a project. I extended the Menu view helper to do the job and made the code available on Github

zf1-navigation-view-helper-bootstrap

Description

This Zend Framework View Helper extends the existing Zend_View_Helper_Navigation_Menu view helper to render dropdown menus compatible with the format required in Twitter Bootstrap. The automatic dropdown functionality requires adding various class, id, and data-toggle attributes, which Zend Framework's menu view helper doesn't natively support

Layke
  • 51,422
  • 11
  • 85
  • 111
Michael Moussa
  • 4,207
  • 5
  • 35
  • 53
1

You can set the class with the setUlClass() method. The following example will set the class to sub_menu on all menu items with a depth 2.

$this->navigation()->menu()
    ->setUlClass('sub_menu')
    ->setOnlyActiveBranch(true)
    ->setRenderParents(false)
    ->setMinDepth(2)
    ->setMaxDepth(2);
Richard Ayotte
  • 5,021
  • 1
  • 36
  • 34