drupal 6 and jquery 1.4/1.5
Asked Answered
F

1

6

is there a way in drupal 6 to use in non admin pages jquery 1.5 / 1.4 without breaking the core functionality on non-admin pages??

Finder answered 3/5, 2011 at 19:49 Comment(0)
U
4

Yes.

Install and enable http://drupal.org/project/jquery_update

Download the version of jQuery you want, and place it alongside the ones included in the module.

Edit the module

function jquery_update_jquery_path() {    
    $curr_uri = request_uri();
     if (strpos($curr_uri,'admin')>0 || strpos($curr_uri,'edit')>0 || strpos($curr_uri,'add')>0){
        $jquery_file = array('none' => 'jquery.js', 'min' => 'jquery.min.js');
        return JQUERY_UPDATE_REPLACE_PATH .'/'. $jquery_file[variable_get('jquery_update_compression_type', 'min')]
;
    }
    else {
        $jquery_file = array('none' => 'jquery-1.5.2.js', 'min' => 'jquery-1.5.2.min.js');
        return JQUERY_UPDATE_REPLACE_PATH .'/'. $jquery_file[variable_get('jquery_update_compression_type', 'min')]
;
    }
}

Use the filename of the version you downloaded.

There is an issue logged about the edit above, but I have the reference at work. I will update the answer tomorrow with the link.

I have this running live on a bunch of sites w/o a problem.

Addendum:

This is the link to the thread / patch about the issue: http://drupal.org/node/775924#comment-2987316

Undecagon answered 4/5, 2011 at 0:10 Comment(2)
+1 Hmm, that's neat, I had Drupal 6 breaking on jQuery updates before (I was using jquery_update, but with more recent versions of jQuery). Didn't look at the code though because of a strict deadline and tried to work my way around it using the older jQuery (stupid if I see how easy it could be solved).Poachy
When you are not in admin, adding, or editing a node, then the version of jQuery you want is loaded (the code blip above uses 1.5.2). If you are doing admin, the the stock jquery.js is loaded (which I think is 1.2.6). I have have this running on live and devel servers w/o any problems. Download/enable the module, add the patch, and then view source on pages to see what happens.Undecagon

© 2022 - 2024 — McMap. All rights reserved.