By ziepe on
Hi everybody.
For a project I use some widgets from the jQuery UI (http://jqueryui.com/) which uses jQuery version 1.6.2. Currently a lower version of jQuery is installed on my Drupal 7 installation. I added a "scripts[]= js/path to js" to the .info file and it seems this solution works fine. Drupal overwrites the current jQuery version this way but, is this the right way to do it ?
Thanks,
Sven
Comments
you can implement
you can implement preprocess_page hook in you template.php or module and replace original path to jquery with path to newer version. The argument passed by reference to this function is an array of all variables used
to render a page, you can amend 'scripts' variable.
http://api.drupal.org/api/drupal/includes--theme.inc/function/template_p...
You can amend scripts variable using string replacement or regular expression.
You can also do this by getting all scripts: $scripts = drupal_add_js() with no parameters, you will get multidimensional array of path to the scripts, change jquery entry and put it back to as plain text using drupal_get_js('header', $scripts);
Best approach is to use the
Best approach is to use the jQuery Update module, it also includes any core scripts that need updating to new releases of jQuery.
I agree that is good solution
I agree that is good solution for somebody who don't know PHP at all and is not able to override Drupal core even in the template.
I prefer changing scripts variable, this give me more control which exactly versions of any scripts you use and you can set different versions for different pages.
I remember an issue with Views for Drupal6 (I'm don't know is it solved yet) where Views UI wasn't working properly with newest version of jquery so it was good to use new version everywhere apart administration pages.