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

Exporting a variable from PHP to JavaScript

Once we get beyond the rudimentary, we will frequently be faced with scenarios where the JavaScript will need to adapt based on the settings and user data which are stored in the database or provided by Drupal modules. In this recipe, we will look at how the Drupal API allows themers to seamlessly export variables from a module and make them available to JavaScript.

Getting ready

We will be using the mysite module created earlier in this book to hold our odds and ends. It is assumed that this module has been created and is enabled.

How to do it...

The following steps are to be performed inside the mysite module folder at sites/all/modules/mysite.

  1. Open the file mysite.module in an editor.
  2. Look for an implementation ...

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