3

I want to add the below external javascript file to the head of my Drupal 6 site.

<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">
stLight.options({
    publisher: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
});
</script>

I want to know if it's OK to do somethng like this, as it's not working at the moment.

function template_preprocess_page(&$vars){
  drupal_set_html_head('<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>');
  drupal_set_html_head('<script type="text/javascript">stLight.options({publisher: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"}); </script>');
}

Someone should kindly assist me feature the links of the external file in the header of every page of my site.

Thank You.

1 Answer 1

6

I think all you need to add is $vars['head']=drupal_get_html_head(); after your code above so that the $head variable passed to your page.tpl.php is updated. If you are doing anything "interesting" with your header, you may need to change that to a .= instead so that it is added to $head instead of just replacing it.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.