dounai9294 2012-08-17 18:57
浏览 44
已采纳

drupal_add_html_head()剥离类型属性

I'm attempting to create a tag inside the head of my site using the drupal_add_html_head() function. It is stripping the type attribute from the tag. It should not be doing this. Does anybody know how to prevent this from occurring?

I'm doing this in the theme's template.php file. Here's my code:

function exampletheme_preprocess_html(&$variables) {
  $rss = array(
    '#type' => 'html_tag',
    '#tag' => 'link',
    '#attributes' => array(
      'rel' => 'alternate', 
      'type' => 'application/rss+xml', 
      'href' => 'http://feeds.feedburner.com/examplefeed', 
      'title' => 'RSS Feed'
    )  
  );  
  drupal_add_html_head($rss, 'rss'); 
}

This results in:

<link rel="alternate" href="http://feeds.feedburner.com/examplefeed" title="RSS Feed" />

I get the same results if I use the drupal_add_html_head_link() function. If I misspell the word 'type' then the attribute shows up. But I don't see anything in the functions that would be stripping 'type' from the html attributes.

  • 写回答

1条回答 默认 最新

  • donmqryh49993 2012-08-17 19:07
    关注

    Try the markup instead

    $script = '<link type="application/rss+xml" rel="alternate" href="http://feeds.feedburner.com/examplefeed" title="RSS Feed" />';
    
    $rss = array(
          '#type' => 'markup',
          '#markup' => $script,
        );
    
    drupal_add_html_head($rss, 'rss');
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle触发器记录修改前后的字段值
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器