【发布时间】:2013-12-19 06:37:20
【问题描述】:
希望有人可以帮助我测试 Magento 自定义模块,但我无法输出。该模块显示在“配置”>“高级”中,所以我认为 Helloworld_Mystuff.xml 已正确完成,但我可能错了!我禁用了本地 Magento 管理实例上的所有缓存。多次刷新缓存,登录/退出管理员,不同的浏览器。如果重要的话,我在使用 apache 的 Mac 上。
/etc/modules/Helloworld_Mystuff.xml(不包括 xml 行)
<config>
<modules>
<Helloworld_Mystuff>
<active>true</active>
<codePool>local</codePool>
</Helloworld_Mystuff>
</modules>
</config>
/app/code/local/Helloworld/Mystuff/controllers/IndexController.php
class Helloworld_Mystuff_IndexController extends Mage_Core_Controller_Front_Action{
public function indexAction(){
echo "test";
//$this->loadLayout()->renderLayout();
}
}
/app/code/local/Helloworld/Mystuff/etc/config.xml
<config>
<modules>
<Helloworld_Mystuff>
<version>0.0.1</version>
</Helloworld_Mystuff>
</modules>
<frontend>
<routers>
<helloworld>
<use>standard</use>
<args>
<module>Helloworld_Mystuff</module>
<frontName>helloworld</frontName>
</args>
</helloworld>
</routers>
</frontend>
</config>
试过了
- /helloworld/index
- /helloworld/index/index
它导致了 404 错误。
我尝试在 /varien/Router/Standard.php 中放置一些调试代码,以查看当我调用测试 URL 时它在寻找哪个类,并且它正在寻找 Mage_Cms_IndexController。因此,在某些地方,我的自定义模块没有加载,因为 Magento 甚至没有尝试加载文件。
编辑: 我在函数内的 Varien/Router/Standard.php 中添加了一些额外的调试代码:
public function match(Zend_Controller_Request_Http $request)
{
//checking before even try to find out that current module
//should use this router
if (!$this->_beforeModuleMatch()) {
return false;
}
$this->fetchDefault();
$front = $this->getFront();
$path = trim($request->getPathInfo(), '/');
if ($path) {
$p = explode('/', $path);
} else {
$p = explode('/', $this->_getDefaultPath());
}
echo "<br />front = " . ($front);
echo "<br />path = " . ($path);
echo "<br />request->getModuleName = ".$request->getModuleName();
输出
front =
path = helloworld/index
request->getModuleName =
front =
path = helloworld/index
request->getModuleName =
front =
path = helloworld/index
request->getModuleName = cms
front =
path = helloworld/index
request->getModuleName = cms
【问题讨论】:
标签: magento