function drupal_add_html_head

Adds output to the HEAD tag of the HTML page.

This function can be called as long as the headers aren't sent. Pass no arguments (or NULL for both) to retrieve the currently stored elements.

Parameters

$data: A renderable array. If the '#type' key is not set then 'html_tag' will be added as the default '#type'.

$key: A unique string key to allow implementations of hook_html_head_alter() to identify the element in $data. Required if $data is not NULL.

Return value

An array of all stored HEAD elements.

See also

theme_html_tag()

12 calls to drupal_add_html_head()
CachePluginBase::cache_start in drupal/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
Start caching the html head.
CachePluginBase::gather_headers in drupal/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
Gather the JS/CSS from the render array, the html head from the band data.
CachePluginBase::restore_headers in drupal/core/modules/views/lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
Restore out of band data saved to cache. Copied from Panels.
drupal_add_html_head_link in drupal/core/includes/common.inc
Adds a LINK tag with a distinct 'rel' attribute to the page's HEAD.
drupal_get_html_head in drupal/core/includes/common.inc
Retrieves output to be displayed in the HEAD tag of the HTML page.

... See full list

File

drupal/core/includes/common.inc, line 307
Common functions that many Drupal modules will need to reference.

Code

function drupal_add_html_head($data = NULL, $key = NULL) {
  $stored_head =& drupal_static(__FUNCTION__);
  if (!isset($stored_head)) {

    // Make sure the defaults, including Content-Type, come first.
    $stored_head = _drupal_default_html_head();
  }
  if (isset($data) && isset($key)) {
    if (!isset($data['#type'])) {
      $data['#type'] = 'html_tag';
    }
    $stored_head[$key] = $data;
  }
  return $stored_head;
}