How can I override/change the contents of the $head variable in page.tpl.php? I looked for a themeable function but don't see one.

Comments

styro’s picture

Looking at http://api.drupal.org/api/4.7/function/phptemplate_page indicates that $head is set by http://api.drupal.org/api/4.7/function/drupal_get_html_head which in turn is set by all different parts of Drupal running http://api.drupal.org/api/4.7/function/drupal_set_html_head (and http://api.drupal.org/api/4.7/function/theme_stylesheet_import for the main stylesheet).

Core functions that call drupal_set_html_head():
http://api.drupal.org/api/4.7/function/drupal_set_html_head/references
(Note: some of your contrib modules may also call it as well)

There are quite a few ways you could change it depending on what you want to do.

1) If you just want to add a line of something yourself, just run drupal_set_html_head() somewhere to add your stuff.

2) You could code whatever you want to replace $head directly into page.tpl.php, but be aware that you might break a few things if you don't do all the stuff that was in $head.

3) You could change/override $head using this technique: http://drupal.org/node/16383

--
Anton
New to Drupal? | Troubleshooting FAQ
Example knowledge base built with Drupal