问题描述
我想在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页面传递带有块形式内容的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!