HOWTO: jQuery with Drupal 4.7
Update: There is now a jquery47 module
While jQuery has been incorporated in the lastest version of Drupal, which will soon become Drupal 5.0. However, you may like to incorporate jQuery effects in your 4.7 installation. This is not recommended if you are not able to patch code and troubleshoot your Drupal installation PHP and Javascript. Much of the information for this tutorial is taken from using jQuery in a 4.7 module on Drupal Groups and jQuery + new drupal_add_js for 4.7 in the Drupal issues queue.
Warning: Backup your database and codebase first. It is likely that following these instructions will break your upgrade path to Drupal 5.0. Proceed at your own risk!
These are the steps I have taken most recently. These instructions will go stale and need to be improved over time.
- Grab a copy of the current Drupal 4.7 codebase.
- Apply the this patch add jQuery which changes some Drupal core functions and adds jQuery library in the /misc directory
- Currently the patch does not apply fully, be prepared for some manual patch of the drupal.js part
- Go through each of the *.js files in /misc (other than jquery.js) and replace all instances of
$(with $id(. This will restore standard drupal effects where the "$" namespace was overwritten by jQuery.
You should now have jquery.js output in your webpages, without sacrificing the existing Drupal javascript effects.
