[themes] How to include and use jquery plugin in my theme

Larry Garfield larry at garfieldtech.com
Sun Aug 24 18:05:34 UTC 2008


On Sunday 24 August 2008 9:28:25 am Sergei Stryukov wrote:
> Hello Konstantin,
>
> You can include this script in page.tpl.php:
>
> <script type="text/javascript"
> src="path-tp-theme/scripts/jquery.corner.js"></script>
>
> Add this code before </head> tag.

No, don't do that.  That skips all of Drupal's JS handling and compression and 
caching mechanisms, and is totally not portable across different sites.  Hard 
coded paths are never correct.

If you're on Drupal 5, then call drupal_add_js from a module or at the top of 
your template.php file.

If you're on Drpual 6, it's even easier.  Simply add the following line to 
your theme's .info file:

scripts[] = jquery.corner.js

And then visit the themes admin page to refresh the info cache.  Drupal will 
handle it from there.

-- 
Larry Garfield
larry at garfieldtech.com


More information about the themes mailing list