【问题标题】:Router for custom module not being recognized by MagentoMagento 无法识别自定义模块的路由器
【发布时间】:2012-01-17 04:43:59
【问题描述】:

我正在关注this 教程来创建自定义模块。由于某种原因,当我点击http://exmaple.com/helloworld/index/index 时,我无法让 magento 识别路由器(我得到一个 Magento 404 错误)。我已经确认该模块已在管理员中启用。这个 tut config.xml 和 IndexController.php 只有 2 个文件。提前谢谢!

模块位于 /code/local/Russ/Helloworld

/etc/config.xml

<config>
    <modules>
        <Russ_Helloworld>
            <version>0.1.0</version>
        </Russ_Helloworld>
    </modules>

    <frontend>
        <routers>
            <helloworld>
                <use>standard</use>
                <args>
                    <module>Russ_Helloworld</module>
                    <frontName>helloworld</frontName>
                </args>
            </helloworld>
        </routers>
    </frontend>

</config>

控制器/IndexController.php

<?php

class Russ_Helloworld_IndexController extends Mage_Core_Controller_Front_Action {
    public function indexAction() {
        echo 'Hello Index!';
    }

}

?>

Magento 1.6.2

【问题讨论】:

  • 您是否清除了管理面板中的缓存?
  • 您是否将文件添加到 app/etc/modules 中?
  • 是的,我做到了。我可以在 Admin 的其他模块中看到自定义模块,并且它已启用
  • 你能显示实时链接吗?还是在本地托管?
  • 在 config.xml 中破坏 XML,并打开开发者模式(参见 index.php)。验证解析错误。

标签: php xml magento zend-controller-router


【解决方案1】:

确保网址中不允许使用商店代码:
(系统 > 配置 > Web > 将商店代码添加到 Urls = 否)

谢谢

【讨论】:

  • 在浪费我的生命 2 个小时之后,这是我的问题,4 年后仍然相关。
  • 有人知道为什么会这样吗?它也解决了我的问题,但我只是想知道为什么,我搜索了代码库但无法找到它。
【解决方案2】:

您是否在 app/etc/modules 中放置了配置文件来激活扩展程序?你需要这个文件来告诉 Magento 你的扩展甚至存在。

试着把它放在 app/etc/modules/Russ_Helloworld.xml 中

<?xml version="1.0"?>
<config>
    <modules>
        <Russ_Helloworld>
            <active>true</active>
            <codePool>local</codePool>
        </Russ_Helloworld>
    </modules>
</config>

然后,清除 Magento 的缓存,它应该会拾取它。

【讨论】:

    猜你喜欢
    • 2016-01-30
    • 2015-07-11
    • 2017-06-15
    • 2012-08-04
    • 1970-01-01
    • 1970-01-01
    • 2015-10-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多