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

前端 未结 4 2088
别那么骄傲
别那么骄傲 2021-01-04 10:18

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\         


        
4条回答
  •  长情又很酷
    2021-01-04 11:12

    I think the problem here stems from the block type you are calling. When you define a type, you're telling Magento to load that model and pass it the appropriate data - which then only exposes the functions defined on that specific model.

    A better solution may be to reference the core block type "core/template" which exposes the ->getData() method, and then load the "multibanners/multibanners" model to work with and output the data.

    {{block type="core/template" category_id="9" name="multibanners" alias="multibanners" template="multibanners/multibanners.phtml"}}
    

    I'm not sure what the proper syntax is to load 'multibanners', but in the multibanners.phtml would be something like this:

    getData('category_id');
    $multibanner = Mage::getModel('multibanners/multibanners')->load($catId);
    
    /**
    ** Generate some output here.
    */
    
    ?>
    

提交回复
热议问题