1
我正在使用zend導航來創建菜單。我想將默認類「活動」更改爲「選定」,我也想將該類添加到活動鏈接的錨點標記。 這裏是我已經把引導
如何在zend導航中更改子菜單活動類?
protected function _initNavigation()
{
$pages = array(
array(
'module' => 'admin',
'label' => 'Services',
'resource' => 'admin',
'controller' => 'services',
'pages' => array(
array(
'module' => 'admin',
'label' => 'Add Services',
'controller' => 'services',
'action' => 'manage',
'route' => 'default',
),
array(
'module' => 'admin',
'label' => 'View Services',
'controller' => 'services',
'action' => 'view',
'route' => 'default',
),
),
)
);
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$config = new Zend_Config($pages);
$navigation = new Zend_Navigation($config);
$view->navigation($navigation);
}
在我看來,劇本在佈局我的示例代碼,我已經把這個下面的代碼
echo $this->navigation()->menu()
->setUlId('menu');
電流輸出
<ul class="navigation" id="menu">
<li class="active">
<a href="/test/public/admin/services">Services</a>
<ul>
<li>
<a href="/test/public/admin/services/manage">Add Services</a>
</li>
<li class="active">
<a href="/test/public/admin/services/view">View Services</a>
</li>
</ul>
</li>
期望輸出
<ul class="navigation" id="menu">
<li>
<a href="/test/public/admin/services">Services</a>
<ul style='display:block;'>
<li>
<a href="/test/public/admin/services/manage">Add Services</a>
</li>
<li>
<a class='selected' href="/test/public/admin/services/view">View Services</a>
</li>
</ul>
</li>
謝謝!有用 –