【问题标题】:Magento set custom template to render widget instanceMagento 设置自定义模板以呈现小部件实例
【发布时间】:2012-03-20 13:23:35
【问题描述】:

我正在尝试使用自定义模板呈现小部件实例。在管理员的 CMS 主页的 Layout Updates XML 部分中,我添加了以下代码:

<reference name="right.hp_right_hot_items">
<block type="mih_banner/widget_banner" template="banner/widget/block-right.phtml"/>
</reference>

其中 'hp_right_hot_items' 是小部件实例标题,但由于某种原因模板设置不正确。

在小部件实例前面的属性中,我设置了布局更新:

显示在:特定页面

页面:CMS 主页

块参考:右列

模板:横幅块模板

有什么想法吗?

【问题讨论】:

    标签: magento widget


    【解决方案1】:

    要使用自定义模板呈现小部件,您必须执行以下操作:

    1. 在所需位置创建 yourfile.phtml 模板
    2. 在 yourModule/etc/ 中创建一个 widget.xml 文件,并为模板参数添加另一个值。例如:
    <parameters>
        <template>
            <values>
                <block_right translate="label">
                    <value>{path_to}/yourfile.phtml</value>
                    <label>Banner Block Template {custom name}</label>
                </block_right>
            </values>
        </template>
    </parameters>
    

    现在,当您进入管理员添加另一个小部件实例时,您应该可以在布局更新部分选择刚刚添加的模板。

    【讨论】:

      【解决方案2】:

      要为块设置模板,请尝试以下操作

      <reference name="right.hp_right_hot_items">
          <action method="setTemplate">
              <template>banner/widget/block-right.phtml</template>
          </action>
      </reference>
      

      【讨论】:

      • 不工作。小部件不显示。我不确定我是否正确引用了小部件。
      猜你喜欢
      • 2013-04-06
      • 2021-12-02
      • 1970-01-01
      • 2013-04-05
      • 2011-08-30
      • 2017-10-31
      • 1970-01-01
      • 1970-01-01
      • 2012-02-17
      相关资源
      最近更新 更多