How to add template suggestions for entities? I need to add a template suggestion for entities in a custom module, similar to how you can add one for nodes. I've seen the ones implemented in the Entity API module, but how do I hook into entity preprocessing so I can add my own?
I found a solution. The Entity API module defines template_preprocess_entity() such that you can add template suggestions during your own preprocessing in a custom module, like for example:

function mymodule_preprocess_entity(&amp;$variables) {
    if($variables['elements']['#entity_type'] = "myentity") {
        $variables['theme_hook_suggestions'][] = "myentity";
    }
}


This runs preprocessing for custom entities built off the Entity API, but not for not nodes or entities built into Drupal core. In order to add template suggestions for Drupal core entities, you need to add it while using the various entity-specific preprocessing hooks provided in Drupal core. For example:

// Preprocessing for taxonomy terms
function mymodule_preprocess_taxonomy_term(&amp;$variables) {
  // Add template suggestion code here.
}

// Preprocessing for user profiles
function mymodule_preprocess_user_profile(&amp;$variables) {
  // Add template suggestion code here.
}

// Preprocessing for comments
function mymodule_preprocess_comment(&amp;$variables) {
  // Add template suggestion code here.
}

// Preprocessing for nodes
function mymodule_preprocess_node(&amp;$variables) {
  // Add template suggestion code here.
}