
Hi, I'm Jon an experienced programmer with a vibrant personality who is passionate about pretty much everything!
I spend much of my time building functional websites bridging the void between robots and humans.
I ran into an issue of needing to run a newer version of the jQuery as the default version that is packaged with Dupal 5 is now quite old. On one particular page we needed to include the latest version of jQuery UI and upgrading jquery in general was not an option as there are issues with page editing with any newer versions.
The solution comes by adding some manual array manipulation within your template.php as follows, focus your attention on the if statement within the function:
/** * Override or insert PHPTemplate variables into the templates. */ function _phptemplate_variables($hook, $vars) { if ($hook == 'page') { if (arg(0) == 'diary') { // retrieve the current listing of scripts $javascript = drupal_add_js(NULL, NULL, 'header'); // unset the current core scripts we don't want unset($javascript['core']['misc/jquery.js']); unset($javascript['core']['misc/drupal.js']); // add our newer version of jquery $core = array( drupal_get_path('module', 'event_diary').'/jquery.js' => array( 'cache' => TRUE, 'defer' => FALSE, ), 'misc/drupal.js' => array( 'cache' => TRUE, 'defer' => FALSE, ), ); // merge both existing and new core script $javascript['core'] = array_merge( $javascript['core'], $core); // update the scripts vars $vars['scripts'] = drupal_get_js(NULL, $javascript); } return $vars; } return array(); }We learn't in the process that the opportunity that using drupal_add_js was gone by the time we enter the _phptemplate_variables function's scope.
This solution is a graceful "hack", ensuring that any other core scripts are not lost.
Problem solved!