Theme suggestions not working for custom templates I have a custom theme hook that I have a tpl for but my theme suggestions are not working. It appears that they are not even being looked for. I am guessing that I am missing something.

Code:

function MYMODULE_theme() {
  module_load_include('inc', 'mymodule', 'theme/mymodule.theme');
  return mymodule_theme_theme();
}

function MYMODULE_theme_theme() {
  $path = drupal_get_path('module', 'MYMODULE') . '/theme';

  return array(
    'mymodule_theme' =&gt; array(
      'variables' =&gt; array('module' =&gt; NULL, 'key' =&gt; NULL, 'body' =&gt; NULL),
      'template' =&gt; 'mymodule-theme',
      'pattern' =&gt; 'mymodule_theme__',
      'file' =&gt; 'mymodule.theme.inc',
      'mail theme' =&gt; TRUE,
      'path' =&gt; $path,
    )
  );
}

function MYMODULE_preprocess_mymodule_theme(&amp;$vars) {
  $module = $variables['module'] ? $variables['module'] : basename(__FILE__, '.theme.inc');
  $functions = array();
  $variables['theme_hook_suggestions'][] = $functions[] = 'MYMODULE_theme__' . $module;
  if (isset($variables['key'])) {
  $variables['theme_hook_suggestions'][] = $functions[] = 'MYMODULE_theme__' . $module . '__' . $variables['key'];
  }
  foreach ($functions as $function) {
    $function = "MYMODULE_preprocess_$function";
    if (function_exists($function)) {
      $function($variables);
    }
  }
}


The theme hook suggestions are being applied as the new preprocess function works.

function MYMODULE_preprocess_MYMODULE_theme__MODULE__KEY(&amp;$vars) {
  dpm($vars);
}


$vars gets printed.

However my MYMODULE-theme--MYMODULE--KEY.tpl.php is not being called.

The base MYMODULE-theme.tpl.php does work.
Theme debug output:

&lt;!-- THEME DEBUG --&gt;
&lt;!-- CALL: theme('MYMODULE-theme') --&gt;
&lt;!-- FILE NAME SUGGESTIONS:
   * MYMODULE-theme--MYMODULE--KEY.tpl.php
   * MYMODULE-theme--MYMODULE.tpl.php
   x MYMODULE-theme.tpl.php
--&gt;


Any ideas?

EDIT: I forgot the calls I have tried. Here they are:

$output = theme('MYMODULE_theme', array('body' =&gt; $body, 'key' =&gt; $key));


and I even tried:

$output = theme(array('MYMODULE_theme', 'MYMODULE_theme__MYMODULE__KEY), array('body' =&gt; $body, 'key' =&gt; $key));
Have you tried making the template name and pattern in the hook_theme implementation uppercase like this:

  'template' =&gt; 'MYMODULE-theme',
  'pattern' =&gt; 'MYMODULE_theme__',


You can also try to remove the pattern completely. It doesn't seem to be necessary at least in the example use case.

Preprocess functions for theme suggestions doesn't work in Drupal 7, and that's why you are manually calling them in your preprocess function. They are being added to the array so they are called but they are not in the correct format so that theme system could handle  them.