2010-04-02 28 views
4

繼我早先的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); 

現在我承認,我已經完全得到了堅持錯誤的結束這個問題,但是很快就沒有想法,而且這一週已經很長時間了。

謝謝,

格蘭特

回答

3

Zend_Navigation似乎確定是否通過檢查任一控制器,動作和模塊鍵的存在使用一個MVC頁面或頁面的Uri;或一個uri鍵。如果這兩個條件都不符合,就會生成報告的錯誤。您的XML文檔中的所有示例看起來都很好,所以我猜測稍後在XML文件中,您會丟失其中一個頁面所需的鍵之一。例如。你有一個動作和控制器,但沒有模塊。

如果你不能夠發現其中一個原因造成的問題,我建議暫時將添加調試行至Zend_Navigation:

var_dump($options);exit; 

到Zend /導航/ page.php文件的222行。這將打印導致錯誤的元素的鍵,這應該可以幫助您計算出您的XML文檔中的哪一個。修復後再刪除此行!

+0

乾杯裝載好,但現在有另一個問題,它實際上獲得導航進入視圖的引導,另一個SO問題很快... – 2010-04-02 14:56:43

1

我最近也有這個錯誤,當我不小心爲其中一個頁面添加了2個條目。