HI,
我的xml文件如下
<?xml version="1.0"?>
<config>
<nav>
<home>
<label>HOME</label>
<controller>index</controller>
<action>index</action>
</home>
<aboutus>
<label>ABOUT US</label>
<controller>about-us</controller>
<action>index</action>
</aboutus>
<destination>
<label>DESTINATION</label>
<controller>destination</controller>
<action>index</action>
</destination>
</nav>
</config>
我的layout.phtml文件中的代码
$config = new Zend_Config_Xml(APPLICATION_PATH.'/configs/clientnav.xml', 'nav');
$container = new Zend_Navigation($config);
$this->navigation()->setContainer($container);
echo $this->navigation();
我得到了结果
<ul class="navigation">
<li class="active">
<a href="/globaltours.com/public/">HOME</a>
</li>
<li>
<a href="/globaltours.com/public/about-us">ABOUT US</a>
</li>
</ul>
但我想要结果
<ul class="navigation">
<li class="active">
<a href="/globaltours.com/public/">HOME</a>
</li>
<li classs="sep"></li>
<li>
<a href="/globaltours.com/public/about-us">ABOUT US</a>
</li>
</ul>
注意两个列表之间的分隔符。帮助我。
答案 0 :(得分:0)
如果您必须拥有sep
并且无法修改您的CSS,那么您可以直接查询导航,然后自己迭代。请注意,如果这样做,您将需要应用自己的ACL规则。
$config = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml');
$container = new Zend_Navigation($config);
$pages = $this->navigation($container)->findAllById("main");
foreach ($pages as $i => $page)
{
if(!$page->getVisible())
continue;
echo $this->menu()->htmlify($page);
}
我使用findAllById()
,但还有很多其他documented here