Radu
Radu

Reputation: 1177

Magento set custom template to render widget instance

I'm trying to render a widget instance with a custom template. In the admin, in my CMS Homepage, in the Layout Updates XML section I've added the following code:

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

where 'hp_right_hot_items' is the Widget Instance Title, but for some reason the template is not set properly.

In the widget instance fronted properties I've set a layout update:

Display On: Specific Page

Page: CMS Home Page

Block Reference: Right Column

Template: Banner Block Template

Any ideas?

Upvotes: 1

Views: 6633

Answers (2)

Radu
Radu

Reputation: 1177

In order to render a widget with a custom template you have to do the following:

  1. Create a yourfile.phtml template on the desired location
  2. Create a widget.xml file in yourModule/etc/ and add another value to the template parameters. Ex:
<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>

Now, when you go to admin to add another widget instance, in the layout updates section you should be able to select the template just added.

Upvotes: 3

Sergey
Sergey

Reputation: 1494

To set template for block try following action

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

Upvotes: 0

Related Questions