【问题标题】:Using CSS #attached doesnt load stylesheet in使用 CSS #attached 不会加载样式表
【发布时间】:2013-09-08 09:44:18
【问题描述】:

我正在使用 Drupal 的 hook_form_alter 将样式表添加到我的一个表单(用户注册表单)中。我的代码确实将样式表添加到jquery.extend(Drupal.settings)sites\/all\/themes\/mytheme\/css\/font-awesome-min.css:1,但这不允许我使用样式表,因为当我引用其中的类时,它们不会加载,因为 CSS 文件没有显示为在<head> 中导入 URL 或链接。任何帮助将不胜感激。

function mytheme_form_alter(&$form, &$form_state, $form_id) {

    if ( $form_id == 'user_register_form' )
    {
    $form['#attached']['css'] = array(drupal_get_path('theme', 'mytheme') . '/css/font-awesome-min.css');
    }

【问题讨论】:

    标签: drupal-7 drupal-theming


    【解决方案1】:

    在 $form['#attached']['css'] 数组的末尾添加 'file',如下所示:

    $form['#attached']['css'] = array(drupal_get_path('theme', 'mytheme') . '/css/font-awesome-min.css', 'file');
    

    【讨论】:

    • 谢谢,除了 jQuery.extend 到 sites\/all\/themes\/mytheme\/css\/font-awesome-min.css 之外,这似乎并没有改变源代码中的任何内容":1,"file":1 - 中没有文件显示。有什么想法吗?
    猜你喜欢
    • 2012-12-11
    • 2013-03-14
    • 2014-02-06
    • 1970-01-01
    • 2013-09-23
    • 2012-11-23
    • 2015-04-08
    • 1970-01-01
    • 2014-07-14
    相关资源
    最近更新 更多