I'm finding that I waste a lot of time researching and guessing through trial-and-error what the name of a template needs to be for a given region, node, or block. Is there some easy short cut to empirically discovering this information? For example is there a Drupal function I could stick in block.tpl.php like "print_desired_template_name()" that would dump the name of the block template it's looking for? Drupal clearly knows what name it's looking for, so I bet there's some way to have it print that info and same myself hours of wasted time. Anyone?

Comments

https://drupal.org/node/1089656 should aid?

there is also the theme developer module which should aid and lastly you can drop a preprocess function in template.php per: http://bri-space.com/content/template-suggestions-drupal-7-themehooksugg... - I've no idea if it would work for anything other than page and node.

function [themename]_preprocess_node(&$vars, $hook) {
  //default template suggestions for all nodes
    $vars['theme_hook_suggestions'] = array();
    $vars['theme_hook_suggestions'][] = 'node';
    //individual node being displayed
    if($vars['page'])
    {
        $vars['theme_hook_suggestions'][] = 'node__page';
        $vars['theme_hook_suggestions'][] = 'node__'.$vars['node']->type.'_page';
        $vars['theme_hook_suggestions'][] = 'node__'.$vars['node']->nid.'_page';
    }
    //multiple nodes being displayed on one page in either teaser
    //or full view
    else
    {
        //template suggestions for nodes in general
        $vars['theme_hook_suggestions'][] = 'node__'.$vars['node']->type;
        $vars['theme_hook_suggestions'][] = 'node__'.$vars['node']->nid;
        //template suggestions for nodes in teaser view
        //more granular control
        if($vars['teaser'])
        {
            $vars['theme_hook_suggestions'][] = 'node__'.$vars['node']->type.'-teaser';
            $vars['theme_hook_suggestions'][] = 'node__'.$vars['node']->nid.'-teaser';
        }
    }
}

Yes, I'd found various documentation and lists with rough algorithms to help figure out the names but Drupal does a lot munging of the text: shifting between underscores and dashes, sometimes using one dash vs two dashes, sometimes upper/lower case changes, sometime part of the template name comes from a string you added in the Drupal admin, other times from a name you selected in the theme's *.info file, etc. I was averaging about an hour of research every time I needed to create a new template just to figure out what the name was supposed to be!

However, I found the easy answer. Just drop this code into the generic template and it will print out the list of more specific templates that Drupal is looking for by name, with the exception that you have to convert underscores to dashes:

print_r($variables['theme_hook_suggestions']);

For example, if you need to find the template name for a specific block, drop that line of code the block.tpl.php file and then every block will dump a list of specific template names that Drupal looks for that individual block. No more guessing, you can just see what name your block is really looking for. It's already saving me a ton of time.