2012-06-18 21 views
0

我正在製作一個已啓用的Magento模塊,並且我的緩存已關閉。我無法訪問我的新Magento模塊的控制器(教程幫助)

使用本教程... http://www.pierrefay.com/magento-create-controller-36

這裏的控制器我被要求在app/code/local/Pfay/Test使用。

class Pfay_Test_IndexController extends Mage_Core_Controller_Front_Action 
{ 
    public function indexAction() 
    { 
    echo 'test index'; 
    } 
    public function mamethodeAction() 
    { 
    echo 'test mymethod'; 
    } 
} 

但是,當我在我的網絡瀏覽器中去magento/Pfay/Test/index,我得到一個404頁面,而不是控制器。

+0

在什麼文件夾中放置了控制器文件? –

+0

你可以發佈你的config.xml請 –

+0

'magneto/app/code/local/Pfay/Test/controllers' – desbest

回答

7

在您複製和粘貼示例代碼,也有betweeen在Pfay_All.xml文件中的下列標記位:

<active> true </active> 
<codePool> local </codePool> 

刪除那些空間讓標籤看起來就像這樣:

<active>true</active> 
<codePool>local</codePool> 

此外,您使用的路徑應該是/test/index/test而不是/Test/index - 即沒有大寫字母T IN測試

+1

很好的接收空白,但我不同意的URL應該包含'Pfay'。爲什麼要這樣? –

+0

Hi @JürgenThelen - 道歉,複製和粘貼artefact!我會更新答案:) +1你的評論:) –

+0

現在它是值得upvote ^^ –

1

請嘗試下列代碼中的任何一個。

magento/Test/index or magento/Test or magento/test 

該命名空間僅用於對模塊進行分組。

+0

他們三個都不工作。 – desbest

+0

你能清除緩存一次,然後再試一次... –

+0

重新檢查config.xml文件 –

1

教程

教程說要在URL中使用Test但應該在URL中有大寫,小寫剛剛發現的一些錯誤。

本教程中的另一個錯誤是<routeurfrontend></routeurfrontend>標籤應改爲<test></test>。你可以在local/Pfay/Test/etc更新。

indexController.php應該被稱作IndexController.php (注意是大寫的I)

又看了其他的答案。其他答案很有用,因爲編寫教程的人對英語不好,所以閱讀可能會令人困惑。你會發現他們糾正的第三個錯誤,所以看看。

相關問題