Question:
How to add javascript files for only a specific node
The code below shows an example of how to add javascript files for a specific node (in this case nid of 339).
function discover_preprocess_page(&$variables) { if ($variables['node']->nid == "339") { drupal_add_js(drupal_get_path('theme', 'example'). 'sites/all/themes/discover/js/swfobject/swfobject.js', 'theme'); drupal_add_js(drupal_get_path('theme', 'example'). 'sites/all/themes/discover/js/jquery/jquery-1.3.2.min.js', 'theme'); drupal_add_js(drupal_get_path('theme', 'example'). 'sites/all/themes/discover/js/common.js', 'theme'); // We need to rebuild the scripts variable with the new script included. $variables['scripts'] = drupal_get_js(); } }