Make body tag editable

Permalink
Hi, I wanted to know if it is ok to make the body tag an editable area so that I can apply different body styles using on unique template?
Many thanks

 
mesuva replied on at Permalink Reply
mesuva
It's best to apply broad classes to a wrapping div around your content, and not directly on the body tag. The reason is, concrete5's editing itself when visible is still within the body tag, so you don't want to accidentally style bits of the interface.

The top of a header file where the body tag is normally looks like this in templates:
...
<body>
    <div class="page <?php echo $c->getPageWrapperClass(); ?>">
...

The getPageWrapper function handily spits out a class representing both your page type and your page template. So it does stuff like this (in the case of a news page type and a full page template):
<div class="page ccm-page page-type-news page-template-full">

That then gives you lots of control over specific page types and layouts, while not targeting anything that isn't your actual page content. You'd use those classes to target the styling as necessary.

In fact, this is pretty much a requirement of 5.7 themes as it's needed to make the slide in panels work correctly, as per:http://www.concrete5.org/documentation/developers/5.7/designing-for...

I get a sense though that you might be referring to something else though..?
ptityop replied on at Permalink Reply
Thanks for the reply ... What i basically want to do is apply a different background color to pages that use the same page template ...
mesuva replied on at Permalink Reply
mesuva
If you are building your own theme, you'd then just use those classes to specifically target the wrapping div on those pages.

If you are using Elemental or another pre-built theme, you can use the custom CSS input when customising a theme and put the rule in there.

The fiddly bit here is that in this case it would be tidier to target body tag to apply the background, otherwise on pages with shorter page contents you might have white sticking out at the bottom... I'd still try to avoid that - you might be able to work around that with some min-heights.