如何从magento中的cms页面传递带有块表单内容的参数 [英] How to pass parameter with block form contents from cms pages in magento
问题描述
我想在 magento 中传递一个带有块代码的变量,如 JSON 类型,
I want to pass a variable with the block code like of JSON type in magento,
{{block type="multibanners/multibanners" category_id="9" name="multibanners" alias="multibanners" template="multibanners/multibanners.phtml"}}
来自 cms 页面内容区域,但我没有收到任何东西.
如果我使用 block 和 action 方法,我很容易得到我的价值.有人知道如何使用自定义块传递变量吗?
from cms pages content area , but I don't receive any thing.
If I use block with action method than I easily get my value.
Anyone know how can I pass variable with my custom block?
推荐答案
我不是 100% 确定您在问什么,但是如果您尝试将变量传递给 multibanners.phtml
上面的代码然后你可以创建另一个类似于 category_id="9"
的属性,在 multibanners.phtml
中你可以使用 $this->getData 获取值("category_id");
I'm not 100% sure what you are asking, but if you are trying to pass a variable to multibanners.phtml
from the code above then you could create another attribute similar to category_id="9"
and in multibanners.phtml
you could get the value using $this->getData("category_id");
例如
{{block ... my_var="value here" ... template="multibanners/multibanners.phtml"}}
在 multibanners.phtml
中:
$this->getData('my_var');
这篇关于如何从magento中的cms页面传递带有块表单内容的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!