By Anonymous (not verified) on
This is almost certainly an incredibly easy to answer question, but I am struggling.
How do I modify the tag on a Drupal 6 page?
I want to integrate Google Earth, which requires a tag to be added to the page head. While this page[http://api.drupal.org/api/function/drupal_set_html_head/6] seems to describe what I want, I can't seem to make it happen...
Could anyone provide me with an example or direction to an example?
Thanks in advance for your time.
Dan
Comments
...
Is it a meta tag or something? Just open up page.tpl.php and paste it in.
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
Hi Jeff, No, it's not a meta
Hi Jeff,
No, it's not a meta tag. It's a bit of JavaScript to initialise the Google Earth API (http://code.google.com/apis/earth/documentation/#using_the_google_earth_api) and I don't need to load it on every page. Just the one.
Any idea how I do that?
...
drupal_set_html_head will usually be ok when used in themeName_preprocess_page and set into the head variable, such as...
..but, as dman points out this is only really ok if whatever you were loading was for that theme only; as soon as you change theme you loose critical functionality. Jamming everything in a node and using the PHP filter is better because at least that wont happen.
Pimp your Drupal 8 Toolbar - make it badass.
Adaptivetheme - theming system for people who don't code.
close...
drupal_set_html_head probably is the one you need - if you are adding the feature through code.
A common problem is that using drupal_set_html_head() in your theme may not work because it's too late in the page building process.
I understand that you only want this to happen on one page, that's fair enough, but how do you plan on selecting that one page?
The very easiest way I see is to copy all the code you want into a normal node content area, as raw HTML, be sure to use 'unfiltered' input format, and it usually just works.
There's no huge difference between a script being inline or in the head.
But if you really want, you can use php input on your node, then call drupal_set_html_head() to add the script tag, and paste the other raw HTML in the content area too.
etc. Note the google instructions require several more script steps...
Anything more clever than that, you should look at existing integration modules. This is not a theme job, so if you find yourself looking at them, it's probably the wrong thing to do. There MAY be a cheap & cheerful theme hack you can do, but it's the wrong place to be adding content functionality.
.dan. is the New Zealand Drupal Developer working on Government Web Standards