[英]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.