Tuesday, June 21, 2011

Including js file in drupal

Adding JavaScript from within a module
<?php
drupal_add_js(drupal_get_path('module', 'mymodule') .'/my_js_file.js');
?>

Adding JavaScript from within a theme
<?php
drupal_add_js(drupal_get_path('theme', 'mytheme') .'/my_js_file.js', 'theme');
?>

Using the theme's .info file (Drupal 6)
name = My theme
description = Theme developed by me.
core = 6.x
engine = phptemplate
version = 6.x-1.0
;
scripts[] = my_script.js

No comments:

Post a Comment