drupal_add_html_head_link

Versions
7
drupal_add_html_head_link($attributes, $header = FALSE)

Add a LINK tag with a distinct 'rel' attribute to the page's HEAD.

This function can be called as long the HTML header hasn't been sent, which on normal pages is up through the preprocess step of theme('html'). Adding a link will overwrite a prior link with the exact same 'rel' and 'href' attributes.

Parameters

$attributes Associative array of element attributes including 'href' and 'rel'.

$header Optional flag to determine if a HTTP 'Link:' header should be sent.

▾ 7 functions call drupal_add_html_head_link()

drupal_add_feed in includes/common.inc
Add a feed URL for the current page.
node_page_view in modules/node/node.module
Menu callback; view a single node.
openid_test_html_openid1 in modules/openid/tests/openid_test.module
Menu callback; regular HTML page with OpenID 1.0 <link> element.
openid_test_html_openid2 in modules/openid/tests/openid_test.module
Menu callback; regular HTML page with OpenID 2.0 <link> element.
template_preprocess_book_navigation in modules/book/book.module
Process variables for book-navigation.tpl.php.
template_preprocess_html in includes/theme.inc
Preprocess variables for html.tpl.php
template_preprocess_maintenance_page in includes/theme.inc
The variables generated here is a mirror of template_preprocess_page(). This preprocessor will run it's course when theme_maintenance_page() is invoked. It is also used in theme_install_page() and theme_update_page() to keep all the variables...

Code

includes/common.inc, line 3077

<?php
function drupal_add_html_head_link($attributes, $header = FALSE) {
  $element = array(
    '#tag' => 'link',
    '#attributes' => $attributes,
  );
  $href = $attributes['href'];

  if ($header) {
    // Also add a HTTP header "Link:".
    $href = '<' . check_plain($attributes['href']) . '>;';
    unset($attributes['href']);
    $element['#attached']['drupal_add_http_header'][] = array('Link',  $href . drupal_http_header_attributes($attributes), TRUE);
  }

  drupal_add_html_head($element, 'drupal_add_html_head_link:' . $attributes['rel'] . ':' . $href);
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.