Use of pattern in hook_theme() I'm trying to implement pattern but It doesn't work.
Here is the implementation of hook_theme() with my pattern:

Call theme('publication__' . 'news', array('bean' =&gt; $bean));

in file atom_publications.module

function atom_publications_theme() {
  return array(
    'publication' =&gt; array(
      'variables' =&gt; array('bean' =&gt; NULL),
      'pattern' =&gt; 'publication__',
      'file' =&gt; 'atom_publications.theme.inc',
      'preprocess functions' =&gt; array('atom_publication_custom_preprocess'),
      'template' =&gt; 'publication',
    ),
  );
}


In file atom_publications.theme.inc write this code:

function atom_publication_custom_preprocess(&amp;$variables) {
}


Files in module dir:


publication.tpl.php
publication--news.tpl.php


But render only publication.tpl.php template. Why?
Looking at theme(), I notice that the "pattern" property is never used. What the function does is using the following code.

  // If there's no implementation, check for more generic fallbacks. If there's
  // still no implementation, log an error and return an empty string.
  if (!isset($hooks[$hook])) {
    // Iteratively strip everything after the last '__' delimiter, until an
    // implementation is found.
    while ($pos = strrpos($hook, '__')) {
      $hook = substr($hook, 0, $pos);
      if (isset($hooks[$hook])) {
        break;
      }
    }


In your case, theme() first looks for publication__news key in theme functions array, and then it looks for the publication key. As in your case there isn't any match for publication__news, it uses publication, and the template file associated with that theme function.  

This is documented in theme().


  If the name contains a double-underscore (__) and there isn't an implementation for the full name, the part before the __ is checked. This allows a fallback to a more generic implementation. For example, if theme('links__node', ...) is called, but there is no implementation of that theme hook, then the 'links' implementation is used. This process is iterative, so if theme('links__contextual__node', ...) is called, theme() checks for the following implementations, and uses the first one that exists:
  
  
  links__contextual__node
  links__contextual
  links
  
  
  This allows themes to create specific theme implementations for named objects and contexts of otherwise generic theme hooks.