How to include different jquery versions based on Drupal theme Drupal is awesome but from time to time you have to modify something to get what you need.
I love latest jquery and I always have my own custom made frontent user facing theme so I thought it would be cool to include latest jquery in my custom made theme and keep the 1.3.2 version that is compatible with drupal in garland theme.
After doing so I can have all the features working like drag and drop, file uploads etc in my administration account and I can use latest coolest jquery plugins on my frontend.
Different jquery versions may not work with drupal extensions and other plugins so you have to keep and eye on that.
Easiest way I found is to install jquery_update module and edit it to actually include theme based override if it exists.
function jquery_update_jquery_path() {
//FIXME - artur modified
if( file_exists(path_to_theme().'/js/jquery.min.js') ){
return path_to_theme().'/js/jquery.min.js';
}
$jquery_file = array( 'none' => 'jquery.js', 'min' => 'jquery.min.js');
return JQUERY_UPDATE_REPLACE_PATH .'/'. $jquery_file[variable_get('jquery_update_compression_type', 'min')];
}
With this function replacing one of the jquery update module functions you can load jquery from theme folder so that every theme could have its own version.
Its not a perfect solution but it does exactly what I need as my admin never uses different themes only garland. My front end users have only my own scripts and cant use drupal generic features so nothing gets broken.
Hope it helps :- )
Comments
Post new comment