Adding classes to the BODY tag.

Permalink 3 users found helpful
I am currently working on a site that only uses 2 different page layouts, but 6 different color schemes.

Right now, my CSS is set up so putting CLASS="red" in the body tag will change everything to the new color scheme. I would really like to integrate my six color options into a custom page attribute or something similar (anything to avoid making 12 different templates), however I have no idea how to do this.

Any recommendations for the best way to put an editable/selectable class in the body tag?

View Replies: View Best Answer
defunct replied on at Permalink Best Answer Reply
defunct
Add a custom attribute in "Pages and Themes" > "Attributes" called bodyclass.

Then your theme header.php you just add:

<body class="<?php echo $c->getCollectionAttributeValue('bodyclass')?>">


Then when you add a page, put in "red" into the Body Class Custom Attribute and voila. it will output

<body class="red">