Overriding Template Files by using hook_theme()

Events happening in the community are now at Drupal community events on www.drupal.org.
RavindraSingh's picture

You will find several other template files as you browse through the module and theme directories of
your site. For example, the custom search module uses custom_search.tpl.php for rendering custom search. The
custom search module creates a number of variables and exposes those variables to the custom_search.tpl.php file.
The designation of the custom_search.tpl.php file as the template file for comments is made through a call to hook_theme() by passing 'template' => 'custom_search' as one of the values in the array. There’s no need to specify the custom_search.tpl.php file extension as Drupal assumes that’s what you mean.
I’ll cover additional details on how to create and expose variables to your template in a bit.

/**
* Implements hook_theme().
*/
function custom_search_theme() {
return array(
'custom_search.tpl.php' => array(
'render element' => 'form',
'template' => 'custom_search-nameform',
),
);

Comments

useful!

rommelxcastro's picture

useful!

STRAIGHT EDGE // WEB DEVELOPER

Feel free to use an example

greta_drupal's picture

Feel free to use an example for overriding a node edit form.

create own template files

RavindraSingh's picture

Help us to create own template files by using modules.

Drupal Event Organization

Group organizers

Group categories

Event type

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: