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(&$theme_registry) {
if (isset($theme_registry['entity'])) {
$entity = &$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.