I wanted to make one of the pages in my site look and feel completely different than the rest of the site. I wanted to use a different style sheet css file for this page and also didn't want to override all the existing styles.
I found a very good post about it on http://drupal.org/node/258756
This code goes inside template.php
<?php
function phptemplate_preprocess_page(&$vars){
if($node = menu_get_object()){ // we check if the current page is a node
if($node->nid == 10){ // this is the page we want to modify, node/10
$css = $vars['css'];
unset($css['all']['module']['modules/system/system.css']);
unset($css['all']['module']['modules/system/defaults.css']);
$vars['styles'] = drupal_get_css($css);
}
}
}
?>The structure of the $vars['css'] variable looks something like this:
Array
(
[all] => Array
(
[module] => Array
(
[modules/node/node.css] => 1
[modules/system/defaults.css] => 1
[modules/system/system.css] => 1
[modules/system/system-menus.css] => 1
[modules/user/user.css] => 1
[sites/all/modules/admin_menu/admin_menu.css] =>
)
[theme] => Array
(
[sites/all/themes/mytheme/layout.css] => 1
)
)
[print] => Array
(
[module] => Array
(
)
[theme] => Array
(
[sites/all/themes/interactivemale/print.css] => 1
)
)
)
Drupal is a great language and is widely used now-a-days in web development. So keeping the codes updated and clear will help a lot and will create less confusion. Also the maintainence would be easy. Thanks for the template. It was very interesting.
accredited online colleges
Thanks for the post but...I found another solution to control the default styles -
not to use the general default stylesheet files, but instead of it
to copy, change and redirect the default stylesheet files for my concrete new theme.
frontline plus for cats
With drupal 6.x, you can use the theme.info file to overwrite the default system css files. For example, to over write the system menu default styling simply add:
stylesheets[all][] = system-menus.css
knol.google.com
Isn't there an easy way to hide the node title by using an in line css override? so not to have to edit any files.
multi zone amplifier
The logic is that this is how it worked in Drupal 6, and we (themers/designers) like it because it's easy. This is a very widely used and recommended technique for removing CSS files.
patent translation
Post new comment