It doesn’t seem to matter whether we’re working as a freelance web developer for companies in Bath, Bristol, Wiltshire or Timbuktu, at some point they will give us a design that has colour variations across groups of pages. Some pages will use purple to highlight text, other will be in orange, others will use a different font, variable width columns, the list goes on. So how can you deal with this without having utterly impenetrable CSS files?
In Magento* it’s easy enough! Simple add a snippet to the Layout Update XML.
<reference name="root"> <action method="addBodyClass"><className>purple</className></action> </reference>
Essentially it just calls the method Mage_Page_Block_Html::addBodyClass() and slaps the className onto the <body> tag, letting you then create css selectors like .purple .someotherselector.
If you’re feeling really clever you could probably programmatically add a class derived from the value of a Product attribute, but that will have to wait for another day…
Looking for a friendly freelance Magento developer? Need some help getting your designs turned into working websites, cost effectively? Why not give us a call on 01380 830224 – we’d be delighted to help…
*I know, I know, not often you hear “Magento” and “easy” in the same sentance.