O'Reilly logo

Drupal 7 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

Adding a variable to all node templates

In this recipe, we will be adding a variable to be made available in all node template files. For this example, the new variable will contain a disclaimer that we will be displaying at the bottom of all nodes.

Getting ready

We will be using the myzen theme created earlier in this book as the example theme in this recipe. It is also assumed that a node.tpl.php file exists in myzen's templates folder as per recipes in earlier chapters. If not, this file will need to be imported from the Zen base theme or a new one will need to be created.

How to do it...

A new variable can be made available to node template files by introducing it via the appropriate preprocess function as follows:

  1. Navigate to the myzen folder ...

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