zachharkey
2/20/2013 - 7:01 AM

Drupal 7 Using Newer Versions of jQuery on certain pages Method 4: Swapping jquery with preprocess page http://drupal.org/node/1058168

Drupal 7 Using Newer Versions of jQuery on certain pages Method 4: Swapping jquery with preprocess page

http://drupal.org/node/1058168

<?php

function MYTHEME_preprocess_page(&$variables) {
  // exclude backend pages to avoid core js not working anymore
  // you could also just use a backend theme to avoid this
  if (arg(0) != 'admin' || !(arg(1) == 'add' && arg(2) == 'edit') || arg(0) != 'panels' || arg(0) != 'ctools') {
    $scripts = drupal_add_js();
    $new_jquery = array(drupal_get_path('theme', 'YOURTHEME') . '/js/jquery-1.7.1.min.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);
  }
}