继我之前的question之后,我仍然遇到将xml文件加载到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加载到bootstrap中,如下所示:
$configNav = new Zend_Config_Xml('../application/config/navigation.xml', 'navigation');
$navigation = new Zend_Navigation($configNav);
$navView->navigation($navigation);
现在我承认,我完全得到了错误的结论,但很快就没有了想法,这已经是漫长的一周了。
谢谢,
捐赠
答案 0 :(得分:3)
Zend_Navigation似乎通过检查控制器,操作和模块键是否存在来确定是否使用Mvc页面或Uri页面;或者是一把钥匙。如果未满足这些条件,则会生成您报告的错误。您的XML文档中的所有示例都很好,所以我猜想在XML文件中稍后您缺少其中一个页面所需的键之一。例如。你有一个动作和控制器,但没有模块。
如果您无法找到导致问题的原因,我建议您通过插入以下内容暂时向Zend_Navigation添加调试行:
var_dump($options);exit;
进入Zend / Navigation / Page.php的第222行。这将打印出导致错误的元素的键,这可以帮助您确定XML文档中的哪一个。修复后再次删除此行!
答案 1 :(得分:1)
最近,当我不小心为其中一个页面添加了两个条目时,我也遇到了这个错误。