Themeing

20
J
U
L
2009
12:16 am

Adding to $body_classes in a custom Drupal theme

I thought I'd pass on some info in case anyone using Drupal 6 is trying to do something similar which I just wrestled with.

I'm developing a revision to this site and in updating my site's look I decided to change some of the columns and add a region. Just for some basic info, I've moved both default sidebars to the right of the content area and created a new region called "above_sidebars" that is the combined width of the sidebars.

I quickly realized when neither of the sidebars were displayed the content region would change from 560px wide to 960px. This width change was coming from the CSS markup for ".no-sidebars #content" in the styles.css file. I couldn't just change the width setting because I needed to be able to remove all sidebars and including my new above_sidebars and allow the content to run the full width of the site.

The CSS class ".no-sidebars" was being inserted in the body statement for the page.

<body class="front page-node no-sidebars lightbox-processed">

 These CSS classes "front", "page-node", "no-sidebars", and "lightbox-processed" added by a page creation variable in Drupal 6 that originated in the Zen theme in Drupal 5. It allows pages to be dynamically themed without having to place tons of conditional statements in their page.tpl.php or other theme pages. Instead the information is worked out in the Drupal code. The name of the variable used to print out the CSS classes may vary based on your theme. Mine is $body_classes. ... [Read More]

Keywords:
join my mailing list
* indicates required

Find me at

Twitter Facebook Fan Page LinkedIn Page Google Profile

Search Photo Archive

Check out these books: