Zend_Navigation无法加载
问题描述:
继我早先的question之后,我仍然遇到了将xml文件加载到Zend_Navigation的问题。Zend_Navigation无法加载
我现在得到以下错误信息:
<b>Fatal error</b>: Uncaught exception 'Zend_Navigation_Exception' with message 'Invalid argument: Unable to determine class to instantiate' in C:\www\mysite\development\website\library\Zend\Navigation\Page.php:223
我试图让我的navigation.xml文件类似于在Zend Documentation的例子,但我似乎无法得到它上班。我的XML文件是这样的:
<?xml version="1.0" encoding="UTF-8"?>
<configdata>
<navigation>
<default>
<label>Home</label>
<controller>index</controller>
<action>index</action>
<module>default</module>
<pages>
<tour>
<label>Tour</label>
<controller>tour</controller>
<action>index</action>
<module>default</module>
</tour>
<blog>
<label></label>
<uri>http://blog.mysite.com</uri>
</blog>
<support>
<label>Support</label>
<controller>support</controller>
<action>index</action>
<module>default</module>
</support>
</pages>
</default>
<users>
<label>Home</label>
<controller>index</controller>
<action>index</action>
<module>users</module>
<role>guser</role>
<resource>owner</resource>
<pages>
<jobmanger>
<label>Job Manager</label>
<controller>jobmanager</controller>
<action>index</action>
<module>users</module>
<role>guser</role>
<resource>owner</resource>
</jobmanger>
<myaccount>
<label>My Account</label>
<controller>profile</controller>
<action>index</action>
<role>guser</role>
<resource>owner</resource>
<module>users</module>
<pages>
<detail>
<label>Account Details</label>
<controller>profile</controller>
<action>detail</action>
<module>users</module>
<role>guser</role>
<resource>owner</resource>
<pages>
<history>
<label>Account History</label>
<controller>profile</controller>
<action>history</action>
<module>users</module>
<role>guser</role>
<resource>owner</resource>
</history>
<password>
<label>Change Password</label>
<controller>profile</controller>
<action>changepwd</action>
<module>users</module>
<role>employer</role>
<resource>employers</resource>
</password>
</pages>
</detail>
...
</navigation>
</configdata>
我加载此XML到引导如下:
$configNav = new Zend_Config_Xml('../application/config/navigation.xml', 'navigation');
$navigation = new Zend_Navigation($configNav);
$navView->navigation($navigation);
现在我承认,我已经完全得到了坚持错误的结束这个问题,但是很快就没有想法,而且这一周已经很长时间了。
谢谢,
格兰特
答
Zend_Navigation似乎确定是否通过检查任一控制器,动作和模块键的存在使用一个MVC页面或页面的Uri;或一个uri键。如果这两个条件都不符合,就会生成报告的错误。您的XML文档中的所有示例看起来都很好,所以我猜测稍后在XML文件中,您会丢失其中一个页面所需的键之一。例如。你有一个动作和控制器,但没有模块。
如果你不能够发现其中一个原因造成的问题,我建议暂时将添加调试行至Zend_Navigation:
var_dump($options);exit;
到Zend /导航/ page.php文件的222行。这将打印导致错误的元素的键,这应该可以帮助您计算出您的XML文档中的哪一个。修复后再删除此行!
答
我最近也有这个错误,当我不小心为其中一个页面添加了2个条目。
干杯装载好,但现在有另一个问题,它实际上获得导航进入视图的引导,另一个SO问题很快... – 2010-04-02 14:56:43