Skip to content
Advertisement

Remove stylesheet selectively in Drupal for page

I am trying to make different layout for the front page. In that process I declared new stylesheet called “front-page.css” and page–front.tpl.php. I am using a Zen subtheme which loads responsive-sidebar.css. I want to remove “responsive-sidebar.css” and load “front-page.css”. The reason I am doing it because the number of grind columns in the later stylesheet is different that former.

I don’t want to use Panels module. I am using Drupal 7.

Advertisement

Answer

The Drupal 7 way is to use hook_css_alter():

function MYMODULE_css_alter(&$css) {
  // Remove defaults.css file. The path will probably change for your theme obviously.
  unset($css[drupal_get_path('theme', 'MYTHEME') . '/css/responsive-sidebar.css']);
}

That hook can be implemented in either a module or a theme.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement