Search code examples
drupal-7drupal-modulesdrupal-theming

applying specific theme to particular form in Drupal 7


I wanted to add a specific theme for particular form in Drupal. for example lets say that I want to apply a template named menu_edit.tpl.php to menu_edit_menu form. How can this be done. Can this be implemented using Hook_theme() function. Can anyone provide me code snippet on how to do this. Any help on this regards will be much appreciated.


Solution

  • you can do this by using template key in hook_theme

    /**
    * Implementation of hook_theme().
    */
    function yourmodule_theme() {
      return array(
       'variables' => array(1) , 
       'template' =>  'my_template' , 
      ) ; 
    }
    

    in this example you can create my_template.tpl.php in the same module directory

    follow this tutorial for more details

    Good luck