How to pass parameter with block form contents from cms pages in magento

Mahmood Rehman picture Mahmood Rehman · Nov 6, 2012 · Viewed 21.6k times · Source

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"}}

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?

Answer

Renon Stewart picture Renon Stewart · Nov 6, 2012

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");

e.g.

{{block ... my_var="value here" ... template="multibanners/multibanners.phtml"}}

In multibanners.phtml:

$this->getData('my_var');