How can I include HTML or PHP code in the head () with a module?

Comments

jsloan’s picture

To send the HTML use drupal_set_html_head()

CZ’s picture

The code in "test.module" dont work:

function drupal_set_header() {

  include "test.html"; 
//  include "test.php"; 
}

Error in the browser: "Fatal error: Cannot redeclare drupal_set_header() (previously declared"

jsloan’s picture

... this function is to be called, not declared. And it was the wrong function. I was referring to drupal_set_html_head() and got the URL wrong, sorry: http://api.drupal.org/api/5/function/drupal_set_html_head

I've got a feeling that you want to include some HTML at the top of the web page rather than alter the HTML head. So take a look at the Module developer's guide: http://drupal.org/node/508 and perhaps also the Theme developer's guide: http://drupal.org/node/509

This may help you define precisely what you want to accomplish.