Adding A CSS Class To The Body Tag

Updated . Posted . Visible to the public.

To add a class via layout XML:

<reference name="root">
    <action method="addBodyClass"><classname>whatever</classname></action>
</reference>

Or to add via code, from a controller or block

if ($root = $this->getLayout()->getBlock('root')) {
    $root->addBodyClass('whatever');
}

Mike Whitby
Last edit
Posted by Mike Whitby to Magento (2012-07-13 09:52)