Saturday, September 14, 2013

Magento Add Block DIV Wrapper/Container Using Template

How to wrap block html in a div wrapper/container (and set class name) using a template file (e.g. local.xml).

e.g. wrap a div wrapper/container around the standard Magento newsletter subscribe block.

<block type="page/html_wrapper" name="subscribe.container" translate="label">
    <label>Subscribe Container</label>
    <action method="setElementClass"><value>subscribe-container</value></action>
    <block type="newsletter/subscribe" name="newsletter" after="leftMenu" template="newsletter/subscribe.phtml"/>