Magento getData没有';不能在Mage_Core_Block_模板自定义块中工作
我这样定义了一个自定义块:Magento getData没有';不能在Mage_Core_Block_模板自定义块中工作,magento,Magento,我这样定义了一个自定义块: <frontend> <layout> <updates> <categorylist module="mymodule"> <file>mymodule.xml</file> </categorylist> </updates> </lay
<frontend>
<layout>
<updates>
<categorylist module="mymodule">
<file>mymodule.xml</file>
</categorylist>
</updates>
</layout>
</frontend>
<global>
<blocks>
<categorylist>
<class>Alias_CategoryList_Block</class>
</categorylist>
</blocks>
</global>
<default translate="label">
<block type="categorylist/list" name="categorylist.list" output="toHtml" after="-" template="mymodule.phtml"/>
{{block type="categorylist/list" categoryid="10"}}
布局是这样的:
<frontend>
<layout>
<updates>
<categorylist module="mymodule">
<file>mymodule.xml</file>
</categorylist>
</updates>
</layout>
</frontend>
<global>
<blocks>
<categorylist>
<class>Alias_CategoryList_Block</class>
</categorylist>
</blocks>
</global>
<default translate="label">
<block type="categorylist/list" name="categorylist.list" output="toHtml" after="-" template="mymodule.phtml"/>
{{block type="categorylist/list" categoryid="10"}}
但不幸的是,$this->getData('categoryid');检索不到任何内容。
不知道怎么了?
我甚至尝试了$this->getCategoryid;但是什么也没有。
有人能帮忙吗
我正在使用Magento 1.7,添加一个具有
<?php echo $this->getCategoryId(); ?>
问题是,我假设布局更新配置将扩展CMS中的代码,但CMS中的代码不应具有块名称和模板参数。因此,我修复了在构造函数中清除模板并在配置中删除布局更新的问题(因为我不需要块来覆盖现有块):
我发现只有在类中声明一个公共函数_toHtml()并将代码放在其中,我才能检索该值。但是在这之后,phtml中的Html代码将不会执行