Hey!

I have an issue with overriding custom module template files in site theme folder.

Relevant hook_theme code

$return['kalenterimailchimpkeikkalista'] = array(
    'template' => 'kalenterimailchimpkeikkalista',
    'variables' => array(
      'keikat' => NULL,
      'viewmode' => NULL
    ),
  );

And then theme call like so:

  $content = theme('kalenterimailchimpkeikkalista', array('keikat' => $keikat,'viewmode' => $view_mode));

And then I have kalenterimailchimpkeikkalista.tpl.php file in module folder(which is working fine) and then I have parent theme inheriting from zurb_foundation and sub themes inheriting from custom parent theme.

No other template file works than the one in the custom module directory.

I'm getting pretty frustrated over this, and this is really something I need to get working. There's something I've missed here, just can't figure out what it is.

Cheers,

Janne

Comments

nevets’s picture

Are you clearing the theme registry after placing the template under the theme?

jiisuominen’s picture

Yeah, I've had the files in place for number of cache clearings. I think that this should be working, but for some reason the only template file that gets registered is one in module folder.

vijaythummar’s picture

Do you have all active themes? what is happening if you remove template file from Modules directory?

Thanks,
Vijay Thummar

jiisuominen’s picture

I actually didn't have those parent themes enabled since everything seemed to be working. I enabled my own custom parent and the ultimate parent theme zurb_foundation. No change.

When I remove template file from modules directory, I get missing files errors.

Warning: include(.....kalenteri_mailchimp/kalenterimailchimpkeikkalista.tpl.php): failed to open stream: No such file or directory in theme_render_template() (line 1525 of .../includes/theme.inc).
Warning: include(): Failed opening '....kalenteri_mailchimp/kalenterimailchimpkeikkalista.tpl.php' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in theme_render_template() (line 1525 of .../includes/theme.inc).

So definitely Drupal doesn't see those files in theme folders.

Other modules in this profile are working, and I can override other templates in themes. Just this one module isn't working.

Hmm.

jaypan’s picture

Are you sure you've named the template file properly in your theme directory?

You can try installing the devel module, and checking the theme registry to find more information.

Contact me to contract me for D7 -> D10/11 migrations.

jiisuominen’s picture

I double & triple checked those, and the names should be correct.

Here's printout from dpm(theme_get_registry(TRUE)); ran just after the theme call in callback function.

kalenterimailchimpkeikkalista (Array, 6 elements)
template (String, 99 characters ) profiles/kalenteri_intra/modules/custom/kalente...
profiles/kalenteri_intra/modules/custom/kalenteri/kalenteri_mailchimp/kalenterimailchimpkeikkalista
variables (Array, 2 elements)
keikat (NULL)
viewmode (NULL)
type (String, 6 characters ) module
theme path (String, 69 characters ) profiles/kalenteri_intra/modules/custom/kalente...
profiles/kalenteri_intra/modules/custom/kalenteri/kalenteri_mailchimp
preprocess functions (Array, 2 elements)
0 (String, 19 characters ) template_preprocess | (Callback) template_preprocess();
1 (String, 21 characters ) contextual_preprocess | (Callback) contextual_preprocess();
process functions (Array, 2 elements)
0 (String, 16 characters ) template_process | (Callback) template_process();
1 (String, 14 characters ) ctools_process | (Callback) ctools_process();

Oh, and I'm trying to implement mailchimp template with custom list of content if that has anything to do with this..

leramos’s picture

Make sure that you return the $return variable at the end of your hook_theme. Can you post your whole code of the hook_theme?

jiisuominen’s picture

Yeah. Theme code should be fine.

Here's the full hook:

/**
 * Implements hook_theme().
 */
function kalenteri_mailchimp_theme() {
  $return = array();

  $return['kalenterimailchimpkeikkalista'] = array(
    'template' => 'kalenterimailchimpkeikkalista',
    'variables' => array(
      'keikat' => NULL,
      'viewmode' => NULL
    ),
  );

  return $return;
}
jaypan’s picture

You haven't given us enough code to see what's happening.

Contact me to contract me for D7 -> D10/11 migrations.

jiisuominen’s picture

Check my other responses, maybe there's something to go with?