Zend 框架:使用 BreadCrumbs 和部分
我在制作定制面包屑时遇到一些麻烦: 我的layout.phtml 我有:
$container = new Zend_Navigation();
$this->navigation($container);
$container->addPage(
array(
'label' => 'Dashboard',
'module' => 'default',
'controller' => 'dashboard',
'action' => 'index',
'pages' =>
array(
array(
'label' => 'Create Order',
'module' => 'default',
'controller' => 'createorder',
'action' => 'index'
),
array(
'label' => 'Query',
'module' => 'default',
'controller' => 'query',
'action' => 'index',
'pages' => array(
array(
'label' => 'View Order',
'module' => 'default',
'controller' => 'order',
'action' => 'vieworder'
)
)
),
array(
'label' => 'Administration',
'module' => 'default',
'controller' => 'admin',
'action' => 'index',
'pages' =>
array(
array(
'label' => 'News and Announcements',
'module' => 'default',
'controller' => 'admin',
'action' => 'addnews',
'pages' => array(
array(
'label' => 'Edit News and Announcements',
'module' => 'default',
'controller' => 'admin',
'action' => 'editnews'
)
)
)
)
)
)
)
);
下一行是:
echo $this->navigation()->breadcrumbs()->setPartial(array('BreadCrumb.phtml','default'));
BreadCrumb.phtml 调用得很好,但我不知道如何在我的BreadCrumb.phtml 中制作ul-li 菜单。如何获取我实际所在的导航? 预先感谢您的任何帮助。安德里亚
I have some trouble making a customized breadcrumb:
I my layout.phtml I have:
$container = new Zend_Navigation();
$this->navigation($container);
$container->addPage(
array(
'label' => 'Dashboard',
'module' => 'default',
'controller' => 'dashboard',
'action' => 'index',
'pages' =>
array(
array(
'label' => 'Create Order',
'module' => 'default',
'controller' => 'createorder',
'action' => 'index'
),
array(
'label' => 'Query',
'module' => 'default',
'controller' => 'query',
'action' => 'index',
'pages' => array(
array(
'label' => 'View Order',
'module' => 'default',
'controller' => 'order',
'action' => 'vieworder'
)
)
),
array(
'label' => 'Administration',
'module' => 'default',
'controller' => 'admin',
'action' => 'index',
'pages' =>
array(
array(
'label' => 'News and Announcements',
'module' => 'default',
'controller' => 'admin',
'action' => 'addnews',
'pages' => array(
array(
'label' => 'Edit News and Announcements',
'module' => 'default',
'controller' => 'admin',
'action' => 'editnews'
)
)
)
)
)
)
)
);
The next line is:
echo $this->navigation()->breadcrumbs()->setPartial(array('BreadCrumb.phtml','default'));
The BreadCrumb.phtml is called well, but I don't know how to make an ul-li menu in my BreadCrumb.phtml. How do I get the navigation I'm actually in?
Thanks in advance for any help. Andrea
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
为此,您的 BreadCrumb.phtml 应如下所示:
然后您将得到如下内容:
To do so, your BreadCrumb.phtml should look like this:
Then you will get something like this:
在视图脚本内,可通过 $this->container 检索 zend 导航容器。容器是可迭代的,因此您可以使用简单的 foreach 循环遍历它(例如
foreach($this->container as $page)
Inside the view script, the zend navigation container is retrievable via
$this->container
. The container is iterable, so you can walk through it with a simple foreach loop (e.g.foreach($this->container as $page)
我找到了渲染面包屑包裹在 ul-li 菜单中的简单解决方案。
您可以将此代码放入您的 breadcrumbs.phtml 中:
I've found simple solution for render breadcrumbs wrapped in ul-li menu.
You can place this code in your breadcrumbs.phtml: