[Drupal] How to add a template file (.tpl.php file) in your Drupal 7 module?

| | 1 min read

In order to add a new theme template file (.tpl.php file), we need to implement hook_theme() in our Drupal 7 module. A theme template need to be specified in the hook_theme() function. They produce HTML and renders Drupal render array elements to the screen.

Usually, a preprocess function is defined corresponding to the theme hook for preparing the variables which is being sent to the template file. Template file are preferred over theme function implementations for creating highly customized layouts.

<div class="comment-overview">
  <?php print drupal_render_children($form); ?>

For more help to use custom templates, please contact us.



Zyxware is a leading Drupal development company with a team of high expertise in Drupal custom module development services since 2006.