Drupal Theming - Use of template.php

 The template.php file contains your sub-theme's functions to manipulate Drupal's default markup. It is one of the most useful files when creating or modifying Drupal themes. 

template.php

A- It contains code that is run every time the template engine is run.

B- template.php is a collection of functions that assist in the theming of the site. It’s for all the conditional logic and data processing of the output - the place to redefine or override theme functions, or add variables that will be made available to the theme engine.

C- PHP: This file must start with a PHP opening tag and typically does not end with a PHP closing tag.

D- There will be one template.php file for a theme, and this one file will define any needed variables.

E- You can add new variables and template suggestions.

With template.php you ca do the following things.

1 - Modify any theme hooks variables or add your own variables, using preprocess or process functions.

2 - Override any theme function. That is, replace a module's default theme function with one you write.

3 - Call hook_*_alter() functions which allow you to alter various parts of Drupal's internals, including the render elements in forms. The most useful of which include hook_form_alter(), hook_form_FORM_ID_alter(), and hook_page_alter(). See api.drupal.org for more information about _alter functions.

No comments:

Write a program in PHP to reverse a number

A number can be written in reverse order. For example 12345 = 54321 <?php   $ num = 23456;   $ revnum = 0;   while ($ num > 1)   {   $...