在drupal 7中使用php文件进行自定义css的困难

时间:2012-05-09 20:41:02

标签: css drupal-7 hook

我想为特定页面使用自定义css。为了实现这个目标,我实现了hook_menu和hook_theme。 我有一个php文件的链接

$url = drupal_get_path('module', 'preview_ipad') . '/css/style-css.php';
drupal_add_css($url);

在这个php文件中,有自定义css:

<?php
    header('content_type : text/css');
?>

* { padding: 0; margin: 0; }

body {
    background: url(./ret/white.png) no-repeat 50% top;
    font-family:Helvetica,Arial,Sans-serif;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    color: <?php echo $_SESSION['color'] ?>;
}

链接存在于我的页面的源代码中,但是存在问题。 css不起作用。

帮助

1 个答案:

答案 0 :(得分:0)

确保最后加载CSS文件。因为默认情况下drupal在模块的CSS文件之后加载主题的CSS文件。

尝试对此代码进行以下更改:

$url = drupal_get_path('module', 'preview_ipad') . '/css/style-css.php';
drupal_add_css($url, array(
    'group' => CSS_THEME,
    'weight' => 1000,
));