Css drupal条件样式表问题!

Css drupal条件样式表问题!,css,drupal-6,themes,Css,Drupal 6,Themes,嗨 我正在尝试创建一个新的drupal主题,它有许多不同的页面、许多不同样式的页面和许多css文件。 该模板适用于具有特定模块的特定网站,当然每个模块都有自己的模板 我在禅宗下发展我的主题。 在template.info中,我定义了manay css文件,我的问题是: 我希望DRUPAL加载特定模块下的每个.CSS文件 drupal有条件样式表,只适用于其他浏览器[如IE6 IE7,…],但在特定模块中没有加载任何内容您可以在主题的template.php文件中编写自己的规则。 我经常使用这个技

嗨 我正在尝试创建一个新的drupal主题,它有许多不同的页面、许多不同样式的页面和许多css文件。 该模板适用于具有特定模块的特定网站,当然每个模块都有自己的模板 我在禅宗下发展我的主题。 在template.info中,我定义了manay css文件,我的问题是: 我希望DRUPAL加载特定模块下的每个.CSS文件
drupal有条件样式表,只适用于其他浏览器[如IE6 IE7,…],但在特定模块中没有加载任何内容

您可以在主题的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);
if($vars['is_front'])){
$vars['template_files']=array();
if(文件存在(路径到主题()./page front.tpl.php')){
$vars['template_files'][]='page front';
}
如果(文件存在(路径到主题()./style-front-ie6.css')){
$vars['ie6_style']。=“\n”。”;
}
如果(文件存在(路径到主题()./style-front-ie7.css')){
$vars['ie7_style']。=“\n”。”;
}
如果(文件存在(路径到主题()./style-front-ie8.css')){
$vars['ie8_style']。=“\n”。”;
}
如果(文件存在(路径到主题()./style-front.css')){
drupal_添加_css(路径到主题()。/style-front.css,'theme','all',FALSE);
}
}否则{
如果(模块_存在('path')){
$alias=drupal_get_path_alias(str_replace('/edit','',$_get['q']);
如果($alias!=$\u GET['q'])){
$template_filename='page';
foreach(分解(“/”,$alias)为$path\u部分){
$template_filename.='-'.$path_part;
$vars['template\u files'][=$template\u filename;
如果(文件存在(路径到主题()。/style-'.$path\u part.-ie6.css')){
$vars['ie6_style']。=“\n”。”;
}
如果(文件存在(路径到主题()。/style-'.$path\u part.-ie7.css')){
$vars['ie7_style']。=“\n”。”;
}
如果(文件存在(路径到主题()。/style-'.$path\u part.-ie8.css')){
$vars['ie8_style']。=“\n”。”;
}
如果(文件存在(路径到主题()。/style-'.$path\u part..css')){
drupal_添加_css(路径到主题()。/style-.$path_part..css,'theme','all',FALSE);
}
}
}
}
}
$css=drupal_add_css();
$vars['css']=$css;
$vars['style']=drupal\u get\u css($css);

将其放入phptemplate_preprocess_page函数中的template.php中,现在如果您有一个带有地址的页面,您可以使用page-catalog.tpl.php和style-catalog.css进行处理。

您可以在主题的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);
if($vars['is_front'])){
$vars['template_files']=array();
if(文件存在(路径到主题()./page front.tpl.php')){
$vars['template_files'][]='page front';
}
如果(文件存在(路径到主题()./style-front-ie6.css')){
$vars['ie6_style']。=“\n”。”;
}
如果(文件存在(路径到主题()./style-front-ie7.css')){
$vars['ie7_style']。=“\n”。”;
}
如果(文件存在(路径到主题()./style-front-ie8.css')){
$vars['ie8_style']。=“\n”。”;
}
如果(文件存在(路径到主题()./style-front.css')){
drupal_添加_css(路径到主题()。/style-front.css,'theme','all',FALSE);
}
}否则{
如果(模块_存在('path')){
$alias=drupal_get_path_alias(str_replace('/edit','',$_get['q']);
如果($alias!=$\u GET['q'])){
$template_filename='page';
foreach(分解(“/”,$alias)为$path\u部分){
$template_filename.='-'.$path_part;
$vars['template\u files'][=$template\u filename;
如果(文件存在(路径到主题()。/style-'.$path\u part.-ie6.css')){
$vars['ie6_style']。=“\n”。”;
}
如果(文件存在(路径到主题()。/style-'.$path\u part.-ie7.css')){
$vars['ie7_style']。=“\n”。”;
}
如果(文件存在(路径到主题()。/style-'.$path\u part.-ie8.css')){
$vars['ie8_style']。=“\n”。”;
}
如果(文件存在(路径到主题()。/style-'.$path\u part..css')){
drupal_添加_css(路径到主题()。/style-.$path_part..css,'theme','all',FALSE);
}
}
}
}
}
$css=drupal_add_css();
$vars['css']=$css;
$vars['style']=drupal\u get\u css($css);
将其放入phptemplate_preprocess_page函数中的template.php中,现在如果您有一个带有地址的页面,则可以使用page-catalog.tpl.php和style-catalog.css