【问题标题】:I want to know why my Magento Module with only controllers is not working我想知道为什么我的只有控制器的 Magento 模块不工作
【发布时间】:2012-09-11 11:01:42
【问题描述】:

这是我的激活文件, 在 app/etc/modules/My_Test.xml

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <modules>
        <My_Test>
            <active>true</active>
            <codePool>local</codePool>
        </My_Test>
    </modules>
</config>

这是我在 app/code/local/MY/Test/etc/config.xml 中的配置文件

<?xml version="1.0" encoding="UTF-8"?>
<config>
    <global>

        <helpers>
            <my_test>
                <class>My_Test_Helper</class>
            </my_test>
        </helpers>
        <models>
            <mytest>
                <class>My_Test_Model</class>
            </my_test>
        </models>
        <blocks>
            <my_test>
                <class>My_Test_Block</class>
            </my_test>
        </blocks>
    </global>

    <frontend>
        <routers>
            <my_test>
                <use>standard</use>
                <args>
                    <module>My_Test</module>
                    <frontName>test</frontName>
                </args>
            </my_test>
        </routers>
    </frontend>

</config>

这是我的控制器代码 在 app/core/local/My/Test/controllers/IndexController.php

<?php
class My_Test_IndexController extends Mage_Core_Controller_Front_Action
{
    public function indexAction()
    {
        echo "This is the Module MyTest";
    }
}

现在当我提供网址时 176.58.99.99/herbal/index.php/test/index/index 176.58.99.99/herbal/index.php/test/ 176.58.99.99/herbal/test/index/index 176.58.99.99/herbal/test/

显示 404 错误

【问题讨论】:

  • 您是否知道模型部分中的开始标签和结束标签不同(mytestmy_test),或者这只是复制/粘贴错误?
  • 另外你说你的文件在位置 MY/Test
  • 上面的错字也会导致问题:)

标签: magento module controllers


【解决方案1】:

您说您的控制器位于app/core/local/My/Test/controllers/IndexController.php,而它应该按如下方式放置:app/code/local/My/Test/controllers/IndexController.php

【讨论】:

    【解决方案2】:

    我有同样的问题,但在我的情况下,它是关于文件权限的。确保您的文件和目录具有适当的访问权限,否则,magento 将永远无法读取这些文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-07-04
      • 1970-01-01
      • 2015-12-16
      • 1970-01-01
      • 1970-01-01
      • 2021-02-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多