I would like to know how to integrate jQuery plugins, inside Drupal. I found some of the jQuery plugins in net, like AmaranJS ( https://github.com/hakanersu/AmaranJS) . But can anyone guide me how to integrate this feature in my Drupal website.
1 Answer
You could include them directly in your theme's page.tpl.php file as but it is not recommended to edit modules or themes since it would affect maintainability.
A cleaner way is to add the js in your theme's info file. Look for the scripts section and add a line to your plugin. Something like this:
scripts[] = js/plugin.js
Another approach would be to implement a custom module where you would call:
drupal_add_js(drupal_get_path('module', '<you-module>') . '/js/plugin.ps');
inside hook_init so it gets included in every page load or the ones you like.
You could also do it in your template.php in your theme folder.
1 Comment
Manuel Alejandro
And Mario, one thing to keep in mind is that if you include it in your theme, it won't load if you switch it or you have more than one theme for some users, unless you include it in everyone of them. So, the module hook_init approach will work every time, no matter the theme. So keeping this in mind, determine which is your best way. Regards.