欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

drupal7 移除 css

shiping1 的头像
下面是drupal7的方法
//leyouji是模块名
function leyouji_css_alter(&$css) {
  // Remove defaults.css file.
  unset($css[drupal_get_path('module', 'system') . '/system.menus.css']);
  unset($css[drupal_get_path('module', 'system') . '/system.messages.css']);
  unset($css[drupal_get_path('module', 'system') . '/system.theme.css']);
  unset($css[drupal_get_path('module', 'system') . '/system.base.css']);
  unset($css[drupal_get_path('module', 'comment') . '/comment.css']);
  unset($css[drupal_get_path('module', 'field') . '/field.css']);
  unset($css[drupal_get_path('module', 'node') . '/node.css']);
  unset($css[drupal_get_path('module', 'search') . '/search.css']);
  unset($css[drupal_get_path('module', 'user') . '/user.css']);
  unset($css[drupal_get_path('module', 'field') . '/theme/field.css']);
  unset($css[drupal_get_path('module', 'ckeditor') . '/ckeditor.css']);
  unset($css[drupal_get_path('module', 'user') . '/user.css']);
  unset($css[drupal_get_path('module', 'views') . '/css/views.css']);
  unset($css[drupal_get_path('module', 'ctools') . '/css/ctools.css']);
  unset($css[drupal_get_path('module', 'views_slideshow') . '/views_slideshow.css']);
  unset($css[drupal_get_path('module', 'taxonomy') . '/taxonomy.css']);
//    unset($css[drupal_get_path('module', 'css') . '/normalize.css']);
}   


function hook_css_alter(&$css) {
  // Remove defaults.css file.
  unset($css[drupal_get_path('module', 'system') . '/defaults.css']);
}



registration required.

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.

share|improve this question
 add comment
up vote 2 down vote accepted

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']);
}


来自 http://stackoverflow.com/questions/14121231/remove-stylesheet-selectively-in-drupal-for-page
普通分类: