私はこれを取得していません。私は標準のXMLベースのZend_Navigationimplを使用しており、いわば箱から出してすぐに使用できます。すべてのページにすべてのメニューオプションがあるようです。私はすべてを試しました-activeOnly、renderSubMenu、renderParentですが、それらはすべて私のすべてまたは何も返しません。私が望んでいること(「ホーム」ノードのアイテムが「ホーム」ページに表示されるなど)は、デフォルトの動作と見なしたもののように見えるため、誤解していると思います。コンテンツを「アクティブ」に設定し始める必要がある場合、XMLでURLまたはコンテナー設定を指定する必要があるのはなぜですか。Zendはアクティブなものを「認識」しています...
例として、このページhttp://my.opera.com/spadille/blog/zend-navigation-with-xml(これは非常に標準的です)を使用して、すべてのトップレベルノードを表示したいと思います(ホーム/バージョン情報/ Product / CONtact)、ただし「アクティブ」ページの子のみ。それはデフォルトの動作ではありませんか?
これを達成するためにパーシャルが必要ですか?
どうもありがとう、
マイク
編集
これがXMLです
<?xml version="1.0" encoding="UTF-8"?>
<configdata>
<nav>
<home>
<label>Home</label>
<controller>index</controller>
<action>index</action>
<module>default</module>
<route>home</route>
</home>
<admin>
<label>Admin</label>
<controller>admin</controller>
<action>index</action>
<module>default</module>
<route>admin</route>
</admin>
<results>
<label>Results</label>
<controller>result</controller>
<action>index</action>
<module>default</module>
<route>results</route>
<pages>
<t>
<label>Charts</label>
<controller>result</controller>
<action>graph</action>
<module>default</module>
<route>charts</route>
</t>
</pages>
</results>
</nav>
</configdata>
routers.ini
routes.home.route = "/"
routes.home.defaults.controller = index
routes.home.defaults.action = index
routes.admin.route = "/admin"
routes.admin.defaults.controller = admin
routes.admin.defaults.action = index
routes.results.route = "/results"
routes.results.defaults.controller = result
routes.results.defaults.action = index
routes.charts.route = "/results/charts"
routes.charts.defaults.controller = result
routes.charts.defaults.action = chart
そして私のブートストラップ
protected function _initNavigation()
{
$this->_bootstrap('layout');
$layout = $this->getResource('layout');
$view = $layout->getView();
$config = new Zend_Config_Xml(
APPLICATION_PATH . '/configs/navigation.xml','nav');
$navigation = new Zend_Navigation($config);
$view->navigation($navigation);
}
そして私の見解。私はもう試した...
$this->navigation()->menu()
そしてこれ。次の行は結果ナビゲーションのサブアイテムを非表示にしますが、それをクリックすると、アイテムとサブアイテムのみが表示され、トップレベルも表示されません(maxDepthのため)
$this->navigation()->menu()->renderMenu(null,array("minDepth"=>0,"maxDepth"=>1,"onlyActiveBranch"=>true,"renderParents"=>true))
編集。
これは私が求めていたものを私に与えますが、ハックのように感じますか?これは適切ですか?
<div class="top_menu">
<?php echo $this->navigation()->menu()->renderMenu(null,array("minDepth"=>0,"maxDepth"=>0,"onlyActiveBranch"=>1,"renderParents"=>true)) ?>
</div>
<div class="sub_menu">
<?php echo $this->navigation()->menu()->renderMenu(null,array("minDepth"=>1,"maxDepth"=>4,"onlyActiveBranch"=>true,"renderParents"=>false)) ?>
</div>