我想在网站构建中使用ZF 1.x
实现下拉菜单在我的应用程序/layouts/layout.phtml中,我有呼叫
$this->navigation()->menu()->renderMenu(
$this->navigation()->findByLabel('My Account'),
array('maxDepth' => 0)
);
在myApp/controller/plugin/navigation.php中,我看到了标记为"我的帐户"的菜单:
$account_container = new Zend_Navigation_Page_Mvc(
array(
'route' => 'account_index',
'label' => 'My Account',
'pages' => array(
new Zend_Navigation_Page_Mvc(
array(
'route' => 'productions_list',
'label' => 'My Productions',
)
),
new Zend_Navigation_Page_Mvc(
array(
'route' => 'productions_create',
'label' => 'Create a Production',
)
),
new Zend_Navigation_Page_Mvc(
array(
'route' => 'account_inbox',
'label' => sprintf('My Inbox (%s)', $ident->getAllUnreadMessagesCount()),
'id' => 'inbox-count'
)
),
new Zend_Navigation_Page_Mvc(
array(
'route' => 'search_search_productions',
'label' => 'Search Productions'
)
),
new Zend_Navigation_Page_Mvc(
array(
'route' => 'search_search_users',
'label' => 'Search Users'
)
),
)
)
);
这会生成
<ul class="navigation">
<li class="active"><a href="/news">Blog</a></li>
...
...
</ul>
我需要使用这样的ul添加嵌套级别:
<ul class="navigation">
<li class="active">
<a href="/news">Blog</a>
<ul>
<li><a href="/somethingelse">link</a></li>
...
...
</ul>
</li>
...
...
</ul>
这样做的方法是什么?我需要它在JavaScript中生成下拉菜单
我找到了解决方案,'maxdepth'=> 1还不够,
需要在子阵列中实现新页面的需要:
$account_container = new Zend_Navigation_Page_Mvc(
array(
'route' => 'account_index',
'label' => 'My Account',
'pages' => array(
new Zend_Navigation_Page_Mvc(
array(
'route' => 'productions_list',
'label' => 'My Productions',
'pages' => array(
new Zend_Navigation_Page_Mvc(
array(
'route' => 'mychildurl',
'label' => 'My Child Label',
)
),
)
),
我想您只需要设置:
'maxDepth' => 1
而不是0。