[英]custom module routing is not working in magento
我是magento的初學者。 我添加了一個自定義模塊,並為該自定義模塊進行了路由。 但是它根本不顯示任何內容,顯示空白頁! 甚至沒有頁面找不到消息。 這是我的代碼。
我的配置文件如下app / code / local / Test / Test / etc / config.xml
<config>
<modules>
<Test_Test>
<version>0.7.1</version>
</Test_Test>
</modules>
<frontend>
<routers>
<test>
<use>standard</use>
<args>
<module>Test_Test</module>
<frontName>test</frontName>
</args>
</test>
</routers>
<layout>
<updates>
<test>
<file>test.xml</file>
</test>
</updates>
</layout>
</frontend>
我在app / etc / modules / Test_Test.xml中的Test_Test.xml文件
<config>
<modules>
<Test_Test>
<active>true</active>
<codePool>local</codePool>
</Test_Test>
</modules>
</config>
我的IndexController.php文件在app / code / local / Test / Test / controllers / IndexAction.php中
<?php
class Test_Test_IndexController extends Mage_Core_Controller_Front_Action
{
public function indexAction()
{
$this->getLayout();
$this->renderLayout();
}
}
我在app / design / frontend / default / default / layout / test.xml中的test.xml文件
<layout version="0.7.0">
<test_index_index>
<reference name="root">
<action method="setTemplate">
<template>page/1column.phtml</template>
</action>
</reference>
<reference name="content">
<block type="test/view" name="test_index_view" template="test/view.phtml" />
</reference>
</test_index_index>
</layout>
我在app / design / frontend / default / default / template / test / view.phtml中的view.phtml文件
<?php
echo "test test test test";
?>
我稱以下網址為網址1:
http://localhost:8888/magento/index.php/test/index/index
網址2:
http://localhost:8888/magento/index.php/test/index
網址3:
http://localhost:8888/magento/index.php/test
網址4:
http://localhost:8888/magento/test
結果它們全部顯示空白頁。 甚至沒有顯示“ 404 not found 1”頁面。 請幫助我找出問題所在。 提前致謝..
多個問題。
etc/config.xml
文件缺少結束符</config>
。 IndexAction.php
。 它必須是IndexController.php
。 indexAction
應該使用$this->loadLayout()->renderLayout();
。 layout/test.xml
使用未定義的塊test/view
。 現在使用page/html
。 解決這些問題后,我可以在裸1.7.0.2上看到view.phtml
的示例輸出。
我在Magento 1.7.0.2中遇到了類似的路由問題,盡管所有模塊的路由鏈都是正確的(已多次檢查拼寫錯誤或元素丟失,在不同的模塊上,清除了緩存(也在var文件夾中)。
經過數小時的搜索並嘗試了所有可能的解決方案之后,Magento 1.7.0.2(而非1.7)中的自定義路由似乎出現了問題。
特別是前三個代碼塊上的模式。 但是,如果有幫助,您可以嘗試:
http://www.pierrefay.com/magento-create-controller-36 (特別是評論中的討論)
希望對您有所幫助,請告訴我們您是否對此問題感到幸運。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.