Use $body_classes To Apply CSS To Specific Pages Or Sections

I love using the http://drupal.org/project/framework theme. It is a great starter theme when building from scratch. Drop the following into template.php and you can easily theme different sections of your site based on the path or section.

<?php
/**
* Intercept page template variables
*
* @param $vars
*   A sequential array of variables passed to the theme function.
*/
function framework_preprocess_page(&$vars) {
  if (!
$vars['is_front']) {
   
// Add unique classes for each page and website section
   
$path = drupal_get_path_alias($_GET['q']);
    list(
$section, ) = explode('/', $path, 2);
   
$vars['body_classes'] .= ' ' . framework_id_safe('page-' . $path) . ' ';
   
$vars['body_classes'] .= ' ' . framework_id_safe('section-' . $section) . ' ';
  }
}
?>

Thanks to this post.

Contact Me

Feel free to contact me.

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.