所以我已经在互联网上搜索了几个小时,但我无法弄清楚这一点。
我编写了一个自定义 Magento 模块,它有一个自定义索引页面,它在一个 Magento 安装 (1.5.0.1) 上运行良好,但在另一个安装 (1.5.1.0) 上运行不佳。问题是当我转到模块的主 URL (domain.com/module) 时,我的自定义模板文件未包含在内。
到目前为止,我知道这一点:
构建页面时会包含布局 XML(因为如果我故意弄乱语法,我会在 system.log 中收到错误)
如果我包含 var_dump($this->getLayout()->getUpdate()->getHandles ());在我的 IndexController.php 中,我可以看到:
1) 我的 IndexController 被调用,所以这一定没问题,
2) 我的模块的句柄被调用,并且具有与我在布局 XML 中指定的完全相同的名称文件。
不调用模板文件。我知道,因为如果是的话,它应该抛出 Magento 异常(出于测试目的,我在该模板文件中的对象上包含了一个不存在的函数调用)。
如果我在布局 XML 文件中将 更改为 ,则模板文件 包含在内,但它当然无法正常工作,因为自定义模块中的块函数未定义。
I have absolutely no idea where I could look next, so any help would be greatly appreciated. I know it must be something simple because it works flawlessly on the other Magento install...
So I have been searching the internet for hours now and I can't figure this out.
I wrote a custom Magento Module that has a custom index page, which works fine on one Magento install (1.5.0.1) but not on another (1.5.1.0). The problem is that my custom template file does not get included when I go to the module's main URL (domain.com/module).
So Far, I know this:
The Layout XML is included when the page is built (because I get errors in system.log if I deliberately mess up the syntax)
If I include var_dump($this->getLayout()->getUpdate()->getHandles()); in my IndexController.php I can see that:
1) my IndexController is called, so that must be okay and
2) The handle for my module is called and has the exact same name I specified in my layout XML file.
The template file is not called. I know because it should throw a Magento exception if it is (I included a non-existent function call on an object in that template file for testing purposes).
If I change <block type="identifier/action" to <block type="core/template" in the layout XML file, the template file is included, but of course it will not work properly because the block functions from the custom module are not defined.
I have absolutely no idea where I could look next, so any help would be greatly appreciated. I know it must be something simple because it works flawlessly on the other Magento install...
发布评论
评论(1)
我的猜测是类别名
identifier/action
无法正确解析为 PHP/Magento 块类。检查您的 Magento 异常日志(var/log/exception.log
,需要在管理控制台中启用日志记录),您可能会看到一些与“无效块类型”相关的错误。尝试
从 PHP 上下文(控制器操作)运行并检查您的块是否确实被实例化。还值得检查您的模板文件是否确实存在于主题中,以及您的自定义块是否继承自模板块。
My guess would be the class alias
identifier/action
doesn't resolve correctly to a PHP/Magento block class. Check your Magento Exception log (var/log/exception.log
, logging needs to be enabled in the Admin Console) and you'll probably see some errors related to "Invalid block type".Try running
from a PHP context (a controller action) and check that your block is actually being instantiated. It's also worth checking that your template file actually exists in your theme, and that your custom block inherits from a template block.