[support] Where to add items to the <head> section for all pages?

Dotan Cohen dotancohen at gmail.com
Sun Sep 16 16:35:07 UTC 2012


On Sun, Sep 16, 2012 at 6:24 PM, Jamie Holly <hovercrafter at earthlink.net> wrote:
> A few things here:
>
> - Theme's can override any tpl.php file. You simple copy the tpl.php
> file to your theme's directory and clear Drupal's cache and you're ready
> to change that file. This isn't "hacking core", but rather the power of
> Drupal's templating layer.
>

The problem is that this theme's tpl file does not include the <head> section.


> - No need for a custom module just to add javascript. The Drupal way in
> D7 for theme's to add javascript is using the .info file, so long as
> that file is to be included on every page rendered by the theme.

That will only let one include JS files in the theme's directory. I
need to include both files on another server, and also inline
javascript in the head section.

> If you
> need something more conditional, then you can use drupal_add_js inside
> mytheme_preprocess_page(). Check out the comments here:
>
> http://api.drupal.org/api/drupal/includes%21common.inc/function/drupal_add_js/7#comment-14344
>

That does look like a solution, but where to put the call to the
function? I it supposed to be in the tpl.php file? I stress that this
theme's tpl.php file does not have a <head> section.


> - You can also use drupal_add_js() to add inline javascript. Check the
> documentation on the link above. You would want the 'inline' type of
> adding in the code.
>
> - Whenever you add a theme override function or change the theme's .info
> file, you must clear Drupal's cache for the changes to be noticed by Drupal.
>

Noted, thanks!

-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com


More information about the support mailing list