How to override template for view mode of a entity within a module? I see in theme suggestion array that I can override template for my custom entity type based on view mode like this: 


  custom_entity__custom_entity__view_mode_name


Now I want to put 


  custom-entity--custom-entity--view-mode-name.tpl.php


inside custom module.

I'm trying something like:

function custom_module_theme_registry_alter(&amp;$theme_registry) {

  if (isset($theme_registry['entity'])) {

    $entity = &amp;$theme_registry['entity'];

    if (!isset($entity['theme paths'])) {
      $entity['theme paths'] = array();
    }

    $entity['theme paths'][] = drupal_get_path('module', 'custom_module') . '/templates';

    if (isset($entity['theme path'])) {
      $entity['theme paths'][] = $entity['theme path'];
      unset($entity['theme path']);
   }
  }
}


So my template file is in custom_module/templates directory.

But after clearing cache always entity.tpl.php is used for all view modes.
I did this using hook_process_HOOK($variables) for nodes view mode tpls :

function view_mode_tpl_preprocess_node(&amp;$vars) {
  $vars['theme_hook_suggestions'][] = 'node__' . $vars['node']-&gt;type . '__' .$vars['view_mode'];
}


hope this will help you.