简体   繁体   中英

drupal_add_html_head() stripping type attribute

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.

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');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM