Quickly create colour themes for Products, Categories and CMS pages in Magento…

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 01225 309162 – we’d be delighted to help…

*I know, I know, not often you hear “Magento” and “easy” in the same sentance.

This entry was posted in Magento, Web Design, Web Development and tagged . Bookmark the permalink.

Comments

Awwww. No one's left a comment yet. Why don't you start things off?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Get Email Alerts

Signup to receive occasional emails with news that may be of interest. Your details will never be disclosed to 3rd parties.




* = required field
I'm interested in...