[英]Creating Custom modules in Magento
我是magento的新手,我想尝试创建自定义模块。 我目前正在关注本教程,因为我觉得它很容易遵循,但是在测试magento是否确实正在加载我的配置文件时遇到错误。
读取“ 控制器文件已加载但类不存在 ”的提示, 但仍显示页面未找到错误。
这是我的app / etc / modules / CompanyName.xml
<?xml version="1.0"?>
<config>
<modules>
<CompanyName>
<active>true</active>
<codePool>local</codePool>
</CompanyName>
</modules>
</config>
这是我的app / local / CompanyName / Helloworld / etc / config.xml
<?xml version="1.0"?>
<config>
<modules>
<CompanyName_HelloWorld>
<version>
0.1.0
</version>
</CompanyName_HelloWorld>
</modules>
<!-- ... -->
<frontend>
<routers>
<!-- the <helloworld> tagname appears to be arbitrary, but by
convention is should match the frontName tag below-->
<helloworld>
<use>standard</use>
<args>
<module>CompanyName</module>
<frontName>helloworld</frontName>
</args>
</helloworld>
</routers>
</frontend>
<!-- ... -->
</config>
-编辑-修复错误/警告日志
我查看了varien.php,并记得我遵循的指南告诉我禁用/注释域,安全,仅HTTP。 因此我删除了注释,现在日志中未出现任何警告错误。 但是我仍然无法使magento读取我的配置文件。 =(
$cookieParams = array(
'lifetime' => $cookie->getLifetime(),
'path' => $cookie->getPath(),
'domain' => $cookie->getConfigDomain(),
'secure' => $cookie->isSecure(),
'httponly' => $cookie->getHttponly()
);
清除缓存可修复 SQL错误,但我仍然无法使magento加载helloworld自定义模块
这令人沮丧。
啊,以为我找到了……我以前没看过。 实际上应该将app / etc / modules / CompanyName.xml命名为app / etc / modules / CompanyName_HelloWorld.xml,并且应该更改模块后的XML元素以反映文件名
<?xml version="1.0"?>
<config>
<modules>
<CompanyName_HelloWorld>
<active>true</active>
<codePool>local</codePool>
</CompanyName_HelloWorld>
</modules>
</config>
The app/etc/modules/CompanyName.xml should rename as app/etc/modules/CompanyName_HelloWorld.xml and the XML should be changed to reflect the filename
<?xml version="1.0"?>
<config>
<modules>
<CompanyName_HelloWorld>
<active>true</active>
<codePool>local</codePool>
</CompanyName_HelloWorld>
</modules>
</config>
And the /app/code/local/CompanyName/HelloWorld/etc/config.xml should be:
<config>
<modules>
<CompanyName_HelloWorld>
<version>0.0.1</version>
</CompanyName_HelloWorld>
</modules>
<frontend>
<routers>
<helloworld>
<use>standard</use>
<args>
<module>CompanyName_HelloWorld</module>
<frontName>helloworld</frontName>
</args>
</helloworld>
</routers>
</frontend>
</config>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.