Quantcast
Channel: Recent posts across whole site
Viewing all articles
Browse latest Browse all 49197

Adding js files to specific pages

$
0
0

I have two different plug-ins that require two different versions of Jquery. I need to have the specific file load according to the page it is on. I have found the following code but have not been able to get it working.

<?php
function yourModuleOrThemeName_preprocess_page(&$variables) {
  if(
arg(0) == 'yourPage') {
   
$scripts = drupal_add_js();
   
   
$new_jquery = array('yourNewJQueryPath/jquery14.js' => $scripts['core']['misc/jquery.js']);
   
$scripts['core'] = array_merge($new_jquery, $scripts['core']);
    unset(
$scripts['core']['misc/jquery.js']);
   
   
$variables['scripts'] = drupal_get_js('header', $scripts); 
  }
}
?>

I have added this script to the template.php. I am not sure if I need to change the function name or not. Also, in the "your page" I have tried both the node name (node/8) and the clean name of "home".

Suggestions?
Thanks!


Viewing all articles
Browse latest Browse all 49197

Trending Articles