我刚刚开始使用magento。我想开发一个简单的magento扩展来显示helloworld。但当我想通过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/tbc
或magento.local/index.php/tbc
,它总是给出404
错误。我安装这个模块是为了更好地处理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_url
和web/secure/base_url
。
任何帮助都将不胜感激。
Mycompany_Tbc.xml
中存在愚蠢错误
<codepool>local</codepool>
应为<codePool>local</codePool>
<?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/local-保存您开发的自定义模块,包括Mage代码覆盖。
我遇到过这样一个问题,因为有一个缓存插件,所以很难解决,但我发现我在Windows中构建了一个运行良好的模块,尽管它在Linux上不起作用。
原因是Magento希望文件夹位于:
app/code/local/Mycompany/Tbc/controllers,我的文件夹名为controllers——在Windows上大小写无关紧要。花了很长时间锻炼。。。