I tried searching for the answer here, but couldn't find it. Sorry if this is a repost.

We have a custom module with a template file. I need to theme this, so I moved the file to my theme folder, cleared caches and it insists on loading the template file from the module.

I have even disabled the theme, and reloaded it. no joy.

I did the exact same with another module, and it worked fine.

Is there anything I am doing wrong? At wits end here. :(

  • Could you post the code for your custom module? – Pontus Nilsson Jun 19 '14 at 9:40
  • Hey Pontus, thanks for the response. We managed to sort it out. The code was for the module was correct, but the hook and template file name weren't. This apparently has to be the same. Guess it's a rookie mistake, but I'm damn glad we managed to find it. – TraaidMark Jun 20 '14 at 5:50

This is an example:

 * Implements hook_theme().
function your_module_name_theme() {
  $themes = array();

  $themes['your_theme_name'] = array(
    'variables' => array(
      'your_variable' => NULL,
    'template' => 'your-template-name',
    'path' => drupal_get_path('module', 'your_module_name') . '/templates',

  return $themes;

Pay attention to template and path keys. And don't delete your template from module, because it will be used by default when template not overriden. Just copy your template to theme folder and clear cache.

|improve this answer|||||
  • Turns out dev figured it out eventually. The theme hook and template file name has to be the "same". Basically we had: pub_owner_dashboard_landing as hook, but our template file was pub-owner-dashboard-landing-PAGE.tpl.php Silly mistake, but I'm damn glad we figured it out. Sorry for the late reply! – TraaidMark Jun 20 '14 at 5:46
  • On a side note, and I am purely asking out of interest sake. Surely, if your module is set up correctly you can just copy the template file to your theme, reset cache and off you go? Your method seems to be a template.php override, which to my mind seems overkill? I had a look at similar solutions yesterday, but they felt wrong to me, because you are doing work to get something working, that should just work by default. Am I missing something here? Our problem turned out to be a code/naming issue, and going by your method we would still have had that problem. Thanks for being awesome! – TraaidMark Jun 20 '14 at 5:56

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.