Skip to content

Instantly share code, notes, and snippets.

@steffenr
Created August 22, 2012 07:27
Show Gist options
  • Save steffenr/3423412 to your computer and use it in GitHub Desktop.
Save steffenr/3423412 to your computer and use it in GitHub Desktop.
set jquery version for specific page (Drupal 6)
<?php
function theme_preprocess_page(&$vars) {
$m_obj = menu_get_object();
if ($m_obj->type == 'product_group') {
// set jQuery 1.5.1 for slider
$path_to_slider = drupal_get_path('module', "slider");
drupal_set_html_head('<script type="text/javascript" src="'. base_path() . path_to_theme() .'/js/libs/jquery-1.5.1.min.js"></script>');
drupal_set_html_head('<script type="text/javascript" src="'. base_path() . $path_to_slider .'/ContentFlow/contentflow.js" load="ML"></script>');
drupal_add_js($path_to_slider ."/contentflow_trigger.js");
drupal_add_css($path_to_slider ."/ContentFlow/contentflow.css");
$vars['head'] = drupal_get_html_head();
// remove standard jquery from drupal scripts array
$scripts = drupal_add_js();
unset($scripts['core']['misc/jquery.js']);
$vars['scripts'] = drupal_get_js('header', $scripts);
}
}
?>
@steffenr
Copy link
Author

steffenr commented Sep 8, 2012

In Drupal 7 you have to use hook_js_alter to achieve the same behaviour - http://drupal.stackexchange.com/questions/28820/how-do-i-update-jquery-to-the-latest-version-i-can-download

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment