【问题标题】:Magento new extension shows 404 pageMagento 新扩展显示 404 页面
【发布时间】:2014-07-03 06:03:39
【问题描述】:

我刚刚开始使用 magento。我想开发一个显示 helloworld 的简单 magento 扩展。但是当我想通过frontname 访问我的扩展页面时,它总是显示我的404 error

我在app/local 中创建了一个文件夹Mycompany。然后我创建了一个文件夹Tbc。然后我创建了etc 文件夹并创建了一个config.xml 文件,看起来像

<?xml version="1.0"?>
 <config>
  <modules>
    <Mycompany_Tbc>
        <version>0.1.0</version>
    </Mycompany_Tbc>
 </modules>
 <frontend>
    <routers>
        <tbc>
            <use>standard</use>
            <args>
                <module>Mycompany_Tbc</module>
                <frontName>tbc</frontName>
            </args>
        </tbc>
    </routers>
    <layout>
        <updates>
            <tbc>
                <file>tbc.xml</file>
            </tbc>
        </updates>
    </layout>
 </frontend>
</config>

然后我在我的模块目录中创建了一个controllers 目录,并在该目录中创建了一个IndexController.php 文件,如

class Mycompany_Tbc_IndexController extends Mage_Core_Controller_Front_Action {
/**
 * index action
 */
    public function indexAction() {
        echo 'reached here';
        die();
    }
}

然后我在app/etc/modules 中创建了一个Mycompany_Tbc.xml 文件,看起来像

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

我可以在管理面板中看到我的模块已启用。 但是现在我想访问magento.local/tbcmagento.local/index.php/tbc,它总是给出404 错误。我已安装 this module 以获得更好的 404 错误,并且由于此扩展,404 页面显示

Page not Found
 We couldn't find a page at the URL you specified. The information below will help a Magento programmer figure out why.

Original Path
Original Path Information /tbc.

Module/Front Name
Module/Front Name: tbc.

No modules claim [tbc] as a <frontName/>`.

我尝试从头开始创建许多扩展,但多次出现相同的错误并清除缓存。我正在使用magento 1.9

注意我在 localhost 和我的虚拟主机中的 magento.local 上执行此操作。我在安装 magento 后创建了虚拟主机,然后更改 config_cache_data 表中的 web/unsecure/base_urlweb/secure/base_url

任何帮助将不胜感激。

【问题讨论】:

    标签: php magento


    【解决方案1】:

    Mycompany_Tbc.xml有一个愚蠢的错误

    <codepool>local</codepool>
    

    应该是&lt;codePool&gt;local&lt;/codePool&gt;

    【讨论】:

    • 老兄,你救了我的手机和我要撞到墙上的头:p :p :p :p :p 向你走去,伙计
    【解决方案2】:
    <?xml version="1.0" encoding="UTF-8"?>
     <config>
      <modules>
        <Mycompany_Tbc>
    
    <!-- Whether our module is active: true or false -->
    
            <active>true</active>
    
    <!-- Which codePool to use: core, community or local -->
            <codePool>local</codePool>
        </Mycompany_Tbc>
      </modules>
    </config>
    

    app/code/core - 包含与基本 Magento 一起分发并构成核心功能的模块。

    app/code/community - 保存由第三方开发的模块

    app/code/local - 保存您开发的自定义模块,包括 Mage 代码覆盖。

    【讨论】:

    • 也许您可以详细说明一下为什么您的答案是该问题的可能解决方案?这对未来的用户也有帮助。
    【解决方案3】:

    我遇到了这样一个由于缓存插件而难以解决的问题,但我发现我在 Windows 中构建了一个可以正常工作的模块,尽管它在 Linux 上不起作用。

    原因是因为 Magento 期望文件夹位于:

    app/code/local/Mycompany/Tbc/controllers 并且我的文件夹被命名为 Controllers - Windows 上大小写无关紧要。花了很长时间才解决...

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-27
      • 2015-05-31
      • 2011-09-05
      • 1970-01-01
      • 2012-01-18
      • 1970-01-01
      • 2016-04-16
      • 1970-01-01
      相关资源
      最近更新 更多