Tuesday, June 21, 2011

Usage of drupal_add_js()

<?php
// This will add a JS file to your head (specifically the $scripts variable in page.tpl.php)
drupal_add_js(drupal_get_path('module', 'my_module') . '/my_module.js');

// This add inline JS to the head of the document
drupal_add_js('alert("Hello!")', 'inline');

// This will add variables in the Drupal.settings object
drupal_add_js(array('my_module' => array('my_setting' => 'this_value')), 'setting');
?>

1 comment:

  1. sir,
    i am totally new to drupal and want to set up a views block to users with similar likings/interests/hometowns etc. can you please tell me how to accomplish that?

    ReplyDelete