How to add a body class to a page in Magento using layout XML

13 August 2015| Post by Graham1 minutes


A good feature of Magento’s layout blocks structure is that it gives you the option to dynamically call methods on any given layout block within any layout handle.

I recently came across an instance of where it would of been really convenient to a body class to the whole frontend account area of Magento.

The below code is how I achieved that :



To add a body class to any other page using the layout XML, then simply copy the following code into the layout handle you would like it to apply to :




We’re hiring an Account Manager. Want in? Apply Here