2011-04-08 125 views
0

我想按照這個非常受歡迎的教程在這個網址:http://alanstorm.com/magento_admin_controllers這個Magento代碼有什麼問題? - 簡單的例子

我嘗試了第一個測試 - 「測試它」下,我沒有得到重定向到我的登錄屏幕,然後到帶空白頁面的控制面板。相反,我得到了...

對url的響應http://mymagentotest.com/index.php/adminhelloworld/產生下面的消息。我一遍又一遍地嘗試,每次都得到完全相同的結果 - 這告訴我,我正在學習如何做到這一點錯誤,我一遍又一遍地犯同樣的錯誤。我需要幫助,或者我們需要幫助,因爲我確信我不是唯一的幫助。

哎呦,我們的壞...你 請求的頁面不存在,我們有一個 罰款猜測原因。如果您直接輸入網址 ,請確保 拼寫正確。如果您點擊 的鏈接來到這裏,鏈接是 過期。

我看不出什麼是錯的,一切看起來都很好,但我不得不猜測配置文件的結構。我認爲這是問題所在。這裏是我的代碼....

app/code/local/Alanstormdotcom/Adminhelloworld/etc的配置文件...

<config> 
<!-- ... --> 
<admin> 
    <routers> 
     <the_name_of_this_element_is_not_important_it_should_be_unique> 
      <use>admin</use> 
      <args> 
       <module>Alanstormdotcom_Adminhelloworld</module> 
       <frontName>adminhelloworld</frontName> 
      </args> 
     </the_name_of_this_element_is_not_important_it_should_be_unique> 
    </routers> 
</admin> 
<!-- ... -->   
</config> 

指數控制器app/code/local/Alanstormdotcom/Adminhelloworld/controllers

<?php class Alanstormdotcom_Adminhelloworld_IndexController extends Mage_Adminhtml_Controller_Action 
{ 
    public function indexAction() 
    { 
     $this->loadLayout(); 
     $this->renderLayout(); 
    } 
} 

app/etc/modulesAlanstormdotcom_adminHelloworld.xml ..

<config> 
    <modules> 
     <Alanstormdotcom_Adminhelloworld> 
      <version>0.1.0</version> 
     </Alanstormdotcom_Adminhelloworld> 
    </modules> 
</config> 

簽名:倒塌,感覺註定失敗。我必須努力學習這些東西,對於我的工作,如果我失敗了,我最終會住在巷子裏的一個漂亮的盒子裏。

回答

2

通常你有XML的兩位應該合併到app/code/local/Alanstormdotcom/Adminhelloworld/etc/config.xml第二個文件,app/etc/modules/Alanstormdotcom_adminHelloworld.xml,反而會是這樣的:

<config> 
    <modules> 
     <Alanstormdotcom_Adminhelloworld> 
      <active>true</active> 
      <codePool>local</codePool> 
     </Alanstormdotcom_Adminhelloworld> 
    </modules> 
</config> 

雖然它看起來像一個巨大的艱苦的鬥爭,以新人你他們要麼掌握它,要麼變得更有能力或學習使用像ModuleCreator這樣的自動化工具。無論發生哪種情況,你都會回過頭來想知道你是如何掙扎的。

相關問題