Setting up variables using preprocess & Process

xaiwant

November 2, 2016

Banner for Setting up variables using preprocess & Process

Preprocess is one of the methodology used to declared the variable so that it can be placed easily on template files. Why does Drupal follow this approach?  It is to keep the Code clean and structured so that it would be pretty readable and easy to understand for post developer & also easy to extend. 

The preprocessing hook provides front-end developer more control over the output and make it more efficient, clean, markup.  It just needs some basic PHP knowledge, but after reading this blog everything will be more clear.

Before I start I am assuming you have basic knowledge of Drupal template files. If not then please visit drupal.org or Goooogle it. Drupal core / Contributed module produces output in template files. If you haven’t seen till now, please look into it, it will help to understand in a deeper level. These templates usually have HTML markup & PHP variable.

For example:  A template file “node.tpl” is located in “modules\node” folder and  their objective is to print node attributes. As you can see node attributes is bound with

Let’s team up and unlock amazing possibilities!