Magento – Adding Widget Instance into Theme via XML

widgets

So I have a few custom widgets instances that I'd like to include into some theme .xml files. However I'd like these to be added via XML rather than as Layout Updates under
New Widget Instance.

I know I can add a widget via XML by also setting all the widget options within the XML, however i'd like to give the client some ability to configure these in the backend themselves.

At the moment the only way I can think of to add a static block and then have a widget added withint the content of that, but this seems a rather unelagant solution compared with just adding a widget instace directly.

Looking for something like below but for a widget rather than a static block

<block type="cms/block" name="cms_footer_links" before="footer_links">
                <action method="setBlockId"><block_id>footer_links</block_id</action>
</block>

Best Answer

Here an example of adding New Products widgets via catalog.xml (or any other file) layout:

<block
  type="catalog/product_widget_new" name="custom_widget_name"
  template="catalog/product/widget/new/column/new_default_list.phtml">
    <!-- populate widget by options -->
    <action method="setData"><name>products_count</name><value>3</value></action>
    <action method="setData"><name>cache_lifetime</name><value>3600</value></action>
</block>