【问题标题】:Pass variable from inline block to template file in magento将变量从内联块传递到magento中的模板文件
【发布时间】:2015-02-08 11:33:28
【问题描述】:

我在magento首页有内容

{{block type="catalog/navigation" template="catalog/navigation/sub_navigation.phtml"}}

这是调用给定父类别 ID 的一组子类别。 现在我想从这个给定的块影响我的$parent_category。我找到了How to pass variable from block to phtml in magento,但它们的表示方式不同。 如何将setData 操作集成到给定的块符号中? 感谢您的帮助!

【问题讨论】:

    标签: php magento


    【解决方案1】:

    你可以像下面提到的方法一样传递数据

    {{block type="catalog/product_list" name="Custom Block" category_id="68" column_count="3" product_count="3" template="catalog/navigation/sub_navigation.phtml"}}
    

    之后在phtml文件中你可以通过下面提到的方法获取数据

    $this->getCategoryId();
    
    or $this->getData('category_id');
    

    谢谢。

    【讨论】:

    • 它就像一个魅力。谢谢。现在我正在努力不止一次地调用它。喜欢:{{block type="catalog/navigation" category_id="5" template="/catalog/navigation/subcategorylisting-distinctive.phtml"}} {{block type="catalog/navigation" category_id="9" template= "/catalog/navigation/subcategorylisting-distinctive.phtml"}} {{block type="catalog/navigation" category_id="38" template="/catalog/navigation/subcategorylisting-distinctive.phtml"}} 知道为什么会这样不工作?
    • 你现在得到了什么?
    • 已解决我在模板中有一个不存在的函数。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2010-11-23
    • 1970-01-01
    • 2021-09-22
    • 2018-12-31
    • 2014-02-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多