I think I'm being a bit thick, but I can't get my theme (a sub theme of Bartik) to override the template in my module.

In my module I've registered the theme template:

<?php
/**
 * Implements hook_theme().
 */
function blah_theme($existing, $type, $theme, $path) { 
  return array(
    'blah_my_template' => array(
      'render element' => 'elements',
      'template' => 'my-template',
      'path' => drupal_get_path('module', 'blah') . '/templates',
    ),
  );
}
?>

my template name is my-template.tpl.php and that is in my module, in a folder called templates. I copied this template and put into my themes templates folder, but it doesn't override, the output is coming from the template in my module. I've cleared caches, I'm even rebuilding the registry ever page load.

Anyone got any ideas?

Comments

tce’s picture

Typical, I spend a long time trying to figure out the problem, but as soon as I post on Drupal I find the answer within 5 minutes.

Apparently it's a bug:

http://drupal.org/node/342350

I renamed my template file to the name of the key (converting underscores to hyphen) and voilà, it works.

/**
 * Implements hook_theme().
 */
function blah_theme($existing, $type, $theme, $path) { 
  return array(
    'blah_my_template' => array(
      'render element' => 'elements',
      'template' => 'blah-my-template', // changed this 
      'path' => drupal_get_path('module', 'blah') . '/templates',
    ),
  );
}
aniket.mohite88’s picture

This works like a charm. Thanks for the solution.

I wanted to override the template provided by Dynamic Banner contrib module.
The key mentioned in the theme function is 'banner_output' & file is banner_output_template.tpl.php

After reading your comment, I copied the original template file provided in the contrib module, pasted it to my active theme & then renamed it (as per your solution) to 'banner-output.tpl.php'.

Now its working. Thanks again.

afagioli’s picture

so precious. Thanks!