这是如何使用 Application.Zend 框架在 layout() 中创建一个 navigation()。好吧,至少有一种方法。CSS 类设置在
把它放到 Bootstrap.php 文件中:
protected function _initNavigation()
{
$this->bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
include APPLICATION_PATH . '/layouts/scripts/menu.phtml';
$view->navigation($container);
}
这允许您在文件 menu.phtml 中为菜单创建一个数组,以便您仍然可以在当前链接上维护活动类。出于某种奇怪的原因,如果您使用它,您必须在数组中包含控制器属性才能获取当前链接上的 CSS 活动类。
将这样的内容放入 /layouts/scripts/menu.phtml 文件中:
$container = new Zend_Navigation(array(
array(
'label' => 'HOME',
'id' => 'tasks',
'uri'=>'/',
'controller' => 'Index'
),
array(
'label' => 'Contact',
'uri' => 'contact',
'controller' => 'Contact'
),
.... more code here ...
将其放入 layout.phtml 文件中:
$options = array('ulClass' => 'menu');