1
嗨 我想創建一個新的drupal主題,它有許多不同的頁面和許多不同風格的頁面和許多css文件。 該模板是針對特定網站的具體模塊,當然每個模塊都有自己的模板 我正在禪宗下開發我的主題。 in template .info我已經定義了manay css文件,我的問題是: 我想要在每個特定模塊中卸載.CSS文件 drupal僅針對其他瀏覽器[如IE6 IE7,...]在特定模塊中加載drupal條件樣式表問題!
嗨 我想創建一個新的drupal主題,它有許多不同的頁面和許多不同風格的頁面和許多css文件。 該模板是針對特定網站的具體模塊,當然每個模塊都有自己的模板 我正在禪宗下開發我的主題。 in template .info我已經定義了manay css文件,我的問題是: 我想要在每個特定模塊中卸載.CSS文件 drupal僅針對其他瀏覽器[如IE6 IE7,...]在特定模塊中加載drupal條件樣式表問題!
您可以在主題的template.php文件中編寫自己的規則。 我經常使用這個技巧,不是針對不同的模塊,而是針對不同的路徑。
if ($vars['is_front']) {
$vars['template_files'] = array();
if (file_exists(path_to_theme().'/page-front.tpl.php')){
$vars['template_files'][] = 'page-front';
}
if (file_exists(path_to_theme().'/style-front-ie6.css')) {
$vars['ie6_style'] .= "\n".'<link type="text/css" href="/'.path_to_theme().'/style-front-ie6.css" rel="stylesheet" />';
}
if (file_exists(path_to_theme().'/style-front-ie7.css')) {
$vars['ie7_style'] .= "\n".'<link type="text/css" href="/'.path_to_theme().'/style-front-ie7.css" rel="stylesheet" />';
}
if (file_exists(path_to_theme().'/style-front-ie8.css')) {
$vars['ie8_style'] .= "\n".'<link type="text/css" href="/'.path_to_theme().'/style-front-ie8.css" rel="stylesheet" />';
}
if (file_exists(path_to_theme().'/style-front.css')) {
drupal_add_css(path_to_theme().'/style-front.css', 'theme', 'all', FALSE);
}
} else {
if (module_exists('path')) {
$alias = drupal_get_path_alias(str_replace('/edit','',$_GET['q']));
if ($alias != $_GET['q']) {
$template_filename = 'page';
foreach (explode('/', $alias) as $path_part) {
$template_filename .= '-'.$path_part;
$vars['template_files'][] = $template_filename;
if (file_exists(path_to_theme().'/style-'.$path_part.'-ie6.css')) {
$vars['ie6_style'] .= "\n".'<link type="text/css" href="/'.path_to_theme().'/style-'.$path_part.'-ie6.css" rel="stylesheet" />';
}
if (file_exists(path_to_theme().'/style-'.$path_part.'-ie7.css')) {
$vars['ie7_style'] .= "\n".'<link type="text/css" href="/'.path_to_theme().'/style-'.$path_part.'-ie7.css" rel="stylesheet" />';
}
if (file_exists(path_to_theme().'/style-'.$path_part.'-ie8.css')) {
$vars['ie8_style'] .= "\n".'<link type="text/css" href="/'.path_to_theme().'/style-'.$path_part.'-ie8.css" rel="stylesheet" />';
}
if (file_exists(path_to_theme().'/style-'.$path_part.'.css')) {
drupal_add_css(path_to_theme().'/style-'.$path_part.'.css', 'theme', 'all', FALSE);
}
}
}
}
}
$css = drupal_add_css();
$vars['css'] = $css;
$vars['styles'] = drupal_get_css($css);
將這個成phptemplate_preprocess_page功能的template.php現在,如果你有地址http://example.com/catalog一個頁面,您還可以使用網頁catalog.tpl.php和風格catalog.css它。