自定义模块路由在洋红色中不起作用


custom module routing is not working in 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>

我在应用程序/等/模块/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();
        }
    }

我的测试.xml应用程序/设计/前端/默认/默认/布局/测试中的文件.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>
我的 view.phtml 文件在 app/design/frontend/default/

default/template/test/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 未找到 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(特别是评论中的讨论)

http://www.magentocommerce.com/knowledge-base/entry/magento-for-dev-part-3-magento-controller-dispatch

希望对您有所帮助,如果您对此问题有运气,请告诉我们。