如何在magento中从cms页面传递带有块形式内容的参数 [英] How to pass parameter with block form contents from cms pages in magento

查看:85
本文介绍了如何在magento中从cms页面传递带有块形式内容的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆