Fix for Messy code to generate a body id and class for css

  1. /**
  2.  * Make additional variables available and override some core variables
  3.  */
  4. function _phptemplate_variables($hook, $vars) {
  5.   switch ($hook) {
  6.     case 'page':
  7.       // generate a section variable as similar to:
  8.       // http://drupal.org/node/16383
  9.       // http://drupal.org/node/32077
  10.       $uri_path = trim($_SERVER['REQUEST_URI'], '/');
  11.       $uri_parts = explode('/', $uri_path);
  12.       $uri_parts_clean = explode('?', $uri_parts[0]);      
  13.       $vars['subsection'] = count($uri_parts);
  14.       $vars['body_id'] = ($vars['is_front']) ? 'front' : str_replace(array('/', '?','='),'-', $uri_path);
  15.       $vars['section_class'] = (empty($uri_parts_clean[0])) ? 'front' : $uri_parts_clean[0];
  16.     break;
  17.   }
  18.   return $vars;
  19. }