From 0d8515deb750fe2a02ee6f9f12860caceed7248f Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Tue, 3 Nov 2009 06:47:23 +0000 Subject: #552478 by pwolanin, samj, dropcube, and sun: Improve link/header API and support on node/comment pages rel=canonical and rel=shortlink standards. --- modules/system/system.api.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'modules/system/system.api.php') diff --git a/modules/system/system.api.php b/modules/system/system.api.php index 36a06df8d..339f82d04 100644 --- a/modules/system/system.api.php +++ b/modules/system/system.api.php @@ -2281,6 +2281,27 @@ function hook_drupal_goto_alter(&$path, &$options, &$http_response_code) { $http_response_code = 500; } +/** + * Alter XHTML HEAD tags before they are rendered by drupal_get_html_head(). + * + * Elements available to be altered are only those added using + * drupal_add_html_head_link() or drupal_add_html_head(). CSS and JS files + * are handled using drupal_add_css() and drupal_add_js(), so the head links + * for those files will not appear in the $head_elements array. + * + * @param $head_elements + * An array of renderable elements. Generally the values of the #attributes + * array will be the most likely target for changes. + */ +function hook_html_head_alter(&$head_elements) { + foreach($head_elements as $key => $element) { + if (isset($element['#attributes']['rel']) && $element['#attributes']['rel'] == 'canonical') { + // I want a custom canonical url. + $head_elements[$key]['#attributes']['href'] = mymodule_canonical_url(); + } + } +} + /** * Alter the full list of installation tasks. * -- cgit v1.2.3