somejkuser
somejkuser

Reputation: 9040

Adding a CSS Class to the inner pages of Zend Navigation

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!

Upvotes: 4

Views: 1339

Answers (2)

Michael Moussa
Michael Moussa

Reputation: 4297

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

Upvotes: 3

Richard Ayotte
Richard Ayotte

Reputation: 5080

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);

Upvotes: 1

Related Questions