3

I have a template file in my custom module folder which I am using to theme a form. Everything works fine when the template file is in the root of my custom module folder. However, I would like to move this template file to another sub-folder in my custom module folder, so that I can basically put all the template files in one folder. My directory structure is such that in the root of the my custom module folder I have (/sites/all/modules/mycustommodule):

mycustommodule.module mycustommodule.info mycustommodule.install mycustommodule_admin.inc

In /sites/all/modules/mycustommodule/mycustomthemes: mycustommodule-example-form.tpl.php mycustommodule-example2-form-tpl.php

This is my hook_theme:

'mycustommodule_example_form' => array(
  'template' => 'mycustommodule-example-form',
  'file' => 'mycustommodule_admin.inc', 
  'render element' => 'form',
),

I would like to know what I would need to do to make the path clear to Drupal that the template file is in that sub-folder. Thanks.

4

Try using 'template' => 'subfolder/mycustommodule-example-form'.

1

or you can move free to your theme's templates directory. Drupal seeks tpl files recursively inside theme directories. you may store your mycustommodule-example-form.tpl.php to

mytheme/templates/mymoduletemplates/mycustommodule-example-form.tpl.php

or

mytheme/templates/mycustommodule-example-form.tpl.php

but this will not work for another theme

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.