Pedro Posada | Remove or disable style sheets for single node on Drupal

Remove or disable style sheets for single node on Drupal

Posted on August 28, 2009 - 3:09pm
<< 6 of 46 >>

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
                )

        )

)

Post new comment

The content of this field is kept private and will not be shown publicly.
Please solve the math question. This way we will know you are not a robot.