Custom node Template for script tags I wanted to add script code to implement "LiveChat" functionality on just three pages of our website. So, I wanted to add one script code given by our LiveChat agency into three webpages of our website.

Script Code

&lt;script src="http://www.examp.com/scripts/invitation.ashx?company=4444"&gt;&lt;/script&gt; 


So, I have created three separate html node templates based on their node ID.

Theses three custom node templates are under

/sites/all/themes/mytheme/templates along with (node.tpl.php and html.tpl.php)


(contact page) html--node--28.tpl.php


Url of this page: www.example.com/contact


(admissions page) html--node--1212.tpl.php


Url of this page: www.example.com/admissions


(market page) html--node--378.tpl.php


Url of this page: www.example.com/market

Code used in all custom node templates (html--node--28.tpl.php, html--node--1212.tpl.php, html--node--378.tpl.php) is the same: 

&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN"
  "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="&lt;?php print $language-&gt;language; ?&gt;" version="XHTML+RDFa 1.0" dir="&lt;?php print $language-&gt;dir; ?&gt;"&lt;?php print $rdf_namespaces; ?&gt;&gt;
&lt;head profile="&lt;?php print $grddl_profile; ?&gt;"&gt;
  &lt;?php print $head; ?&gt;
  &lt;title&gt;&lt;?php print $head_title; ?&gt;&lt;/title&gt;
  &lt;?php print $styles; ?&gt;
 &lt;/head&gt;
&lt;body&lt;?php print $attributes;?&gt;&gt;
&lt;?php print $scripts; ?&gt;
//Adding script for LiveChat
&lt;script src="http://www.examp.com/scripts/invitation.ashx?company=4444"&gt;&lt;/script&gt;
  &lt;div id="skip-link"&gt;
    &lt;a href="#main-content" class="element-invisible element-focusable"&gt;&lt;?php print t('Skip to main content'); ?&gt;&lt;/a&gt;
  &lt;/div&gt;
  &lt;?php print $page_top; ?&gt;
  &lt;?php print $page; ?&gt;
  &lt;?php print $page_bottom; ?&gt;
&lt;/body&gt;
&lt;/html&gt;


But, I am not able to see my script (&lt;script src="http://www.examp.com/scripts/invitation.ashx?company=4444"&gt;&lt;/script&gt;) when I debugged it in view pagesource.

Thanks!
Instead of adding three template files for three nodes with the same content in it in my opinion will be a better solution to add the JS file conditionally using drupal_add_js

For eg:



 $allowed_nid = array(28, 1212, 38);
 if(in_array(arg(1), $allowed_nid)){
  drupal_add_js("http://www.examp.com/scripts/invitation.ashx?company=4444", "external");
 }



You can add the snippet in a hook_init function in any of your custom modules. (Best is add in a custom utility module which hold all general function to be used throughout.)
Else you can add it in your theme's template.php in the template_preprocess_page function.