4

Help including js files into the script.js file

http://drupal.org

I am new to Drupal and I am trying to create a module that requires js. I have successfully created the module. I have successfully created the script.js file. Now I tried to include other js files $.include('script2.js') but it does not work. It should be that easy, right?

Then I tried a different method. The template.php

function _phptemplate_variables($hook, $vars) {
  if ($hook == 'page') {
    // Add the script.js file  

drupal_add_js(path_to_theme() .'/script2.js');

    // Reload the scripts variable to include the added file
    $vars['scripts'] = drupal_get_js();
return $vars;
  }
   return array();
}

and the page.tpl.php method

<?php
print _phptemplate_variables($hook, $vars);
?>

but it does not work either, it only adds the follwoing lines to my source:

<script type="text/javascript"> </script> 
Array

What's up with that!?

Thanks for any suggestions,
Tiffany

Read »
Created by Dplanet 1 year 14 weeks ago
Category: Theming   Tags:

PSD to Drupal Theme

Drupal Development

Module Development

Get an Estimate

Tags for Help including js files into the script.js file

Recent comments