Preprocess functions
Understanding the possibilities of using preprocess functions can greatly reduce theming time and increase theme sustainability.
“The main role of the preprocessor is to setup variables to be placed within the template (.tpl.php) files” (drupal.org documentation). Preprocess functions can create, manipulate, and unset variables before page rendering to ultimately allow you to dynamically alter content before presentation. Not only can the content, but which template file is called can be modified as well by modifying the array of template file suggestions. This, along with the ability to dynamically alter element attributes, such as CSS classes, IDs, and RDFa attributes based on context allows you to create dynamic site content, layout and styles, while also providing a framework for providing semantically rich RDF data.
Preprocess functions are a powerful aspect of the Drupal theme system. This session will be dividing into thirds, first discussing the overall idea of preprocess functions, how they work and what they can do, then examples will quickly show some of the possibilities, and finally we will wrap up with a short conversation about the philosophy of the drupal theme system, content and design separation, and the role preprocess functions tie into both worlds.
This topic was discussed at DrupalCamp Colorado.
Pre-requisites:
Attendees should be relatively comfortable with basic PHP and at least have a general understanding of the templating system
Files:
The template.php file and presentation can be downloaded directly from the pingVision website via:
- Login to post comments
Comments
no screencast?
Just wondering