Magento新扩展显示404页面

时间:2014-07-03 06:03:39

标签: php magento

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

我在Mycompany中创建了一个文件夹app/local。然后我创建了一个文件夹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();
    }
}

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

<?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后创建了虚拟主机,然后更改web/unsecure/base_url表中的web/secure/base_urlconfig_cache_data

非常感谢任何帮助。

3 个答案:

答案 0 :(得分:1)

Mycompany_Tbc.xml

中存在愚蠢的错误
<codepool>local</codepool>

应为<codePool>local</codePool>

答案 1 :(得分:0)

<?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代码覆盖。

答案 2 :(得分:0)

由于缓存插件,我遇到了这样难以解决的问题,但我发现我在Windows中构建了一个运行良好的模块,虽然它在Linux上不起作用。

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

app / code / local / Mycompany / Tbc / controllers和我的文件夹名为Controllers - 案例在Windows上无关紧要。花了很长时间才解决...