Preprocess and stylesheet problem

chandamon - June 16, 2008 - 04:54

I have tried to procure the dynamic style sheet for different paths and pages. But I encountered a problem when I wrote the preprocess_page code into the template.php, the following error in the admin page was shown and nothing happens for the style...

* warning: Cannot modify header information - headers already sent by (output started at /home/chandamo/www/www/testplatz/themes/blue_bars/template.php:19) in /home/chandamo/www/www/testplatz/includes/common.inc on line 141.

The code I wrote in the template.php is copied(from http://drupal.org/node/225868):

<?php
function drop_preprocess_page(&$variables) {
 
$front_style = path_to_theme() .'/front-page.css';
 
$path_style = path_to_theme() .'/path-'. arg(0) .'.css';

  if (
file_exists($front_style) && $variables['is_front']) {
   
$include_style = $front_style;
  }
  elseif (
file_exists($path_style)) {
   
$include_style = $path_style;
  }

  if (isset(
$include_style)) {
   
drupal_add_css($include_style, 'theme', 'all', FALSE);
   
$variables['styles'] = drupal_get_css();
  }
}
?>

Does anyone have any clue about it? And is it the only method I can have a dynamic style sheet applied to different pages? Coz editing .info couldn't do what I want.

Thanks a lot.

 
 

Drupal is a registered trademark of Dries Buytaert.