2013-11-01 14 views
1

我正在構建Drupal 7網站。我有主路徑: sites/all/themes/MYSITE/css/main.css。從定製單頁中刪除主題css

我在首次創建自定義內容類型的方式上創建了一個自定義頁面,並在該頁面之後創建了一個自定義頁面 - custom-page.tpl.php。

在頁面 - custom-page.tpl.php中我插入了我的html代碼和相應的css代碼。

我遇到的問題是main.css在我的自定義頁面中發生衝突。我嘗試了不同的方式來禁用它,但不幸的是沒有成功。

我試着用這樣的:

$arrCSS = drupal_add_css(); 
echo '<pre>'; 
print_r($arrCSS); 
unset($arrCSS['all']['will']['sites/all/themes/will/css/main.css']); 

輸出,我用的print_r($ arrCSS)得到的是:

[sites/all/themes/will/css/main.css] => Array 
    (
     [group] => 100 
     [every_page] => 1 
     [media] => all 
     [type] => file 
     [weight] => 0.003 
     [preprocess] => 1 
     [data] => sites/all/themes/MYSITE/css/main.css 
     [browsers] => Array 
      (
       [IE] => 1 
       [!IE] => 1 
      ) 

    ) 

每樣的幫助是值得歡迎的。 在此先感謝。

+0

你有沒有嘗試過這樣的:http://stackoverflow.com/questions/14121231/remove-stylesheet-selectively-in-drupal-for-page 希望有所幫助。 – magicRoot

回答

1

要取消設置CSS文件,您應該使用Drupal中可用的HOOK_css_alter鉤子。

假設你的主題被命名爲will

function will_css_alter(&$css) 
{ 
    if() { //Unset CSS file if the current page is your custom page 
     $path = drupal_get_path('theme', 'will'); 
     unset($css[$path . '/css/main.css']); 
    } 
} 
+0

太棒了!謝謝 ! – user2834820

相關問題