O'Reilly logo

Drupal 6 Theming Cookbook by Karthik Kumar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Including JavaScript files from a theme

This recipe will list the steps required to include a JavaScript file from the .info file of the theme. We will be using the file to ensure that it is being included by outputting the standard Hello World! string upon page load.

Getting ready

While the procedure is the same for all the themes, we will be using the Zen-based myzen theme in this recipe.

How to do it...

The following steps are to be performed inside the myzen theme folder at sites/all/themes/myzen.

  1. Browse into the js subfolder where JavaScript files are conventionally stored.
  2. Create a file named hello.js and open it in an editor.
  3. Add the following code:
    alert("Hello World!!");
    
  4. Save the file and exit the editor.
  5. Browse back up to the myzen folder and ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required