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

Optimizing using hook_preprocess()

This recipe will demonstrate using the hook_preprocess() function in a module. We will be using it to seemingly export settings from one template file to another by making information from the node template available to the page template file. In this example, we will be adding the author's roles into the class list of the BODY tag as well as part of the content of the node.

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 the node.tpl.php and page.tpl.php files exist in myzen's templates folder.

Just as with the previous recipe where we added our preprocess function to a module, we will be adding our function here into the ...

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