If you are trying to to implement Innerfade in Drupal having used it on standard HTML websites (ike I have) you may come across a few problems getting it working. Here’s a quick how-to to get it running.
Drupal (or WordPress), jQuery and $
You’ll find that when trying to insert jQuery into Drupal you get the JavaScript error
error $ is not a function
This is because some other libraries also use the $ sign and Drupal uses such libraries. Luckily jQuery can handle this so within your code, just replace $ with jQuery (see below).
Only including Innerfade on a single page
If you want to use Innerfade only on a single page as I did, you can create (or edit) the tpl fiel for that particular node and insert your code in there. If that makes no sense to, go to drupal.org and start reading.
Adding JavaScript to Drupal
The best way to add JS to Drupal is to use it’s core function drupal_add_js. This can save problems so use it.
Putting it all together
The below code is what I added to my node’s tpl between PHP tags. I then added the Div with the below ID using the node edit form and added the images too. Save / upload everything and you’re good to go.
drupal_add_js(base_path() . ‘sites/all/libraries/innerfade/jquery.innerfade.js’);
drupal_add_js(‘
jQuery(document).ready(function(){
jQuery(“#home-rotate-3″).innerfade({
speed: 1000,
timeout: 5000,
type: “sequence”,
containerheight: “398px”
});
});
‘, inline);
You will obviously need to download the innerfade js file and upload it to the above directory (or another of your choice) but it should work.