Dude, Where are my Templates? Using the Drupal 7 Theme Developer to find the way.
The first line of the description of the Drupal Theme Developer Module says that it is "Firebug for Drupal themeing". I couldn't agree more. This is the ultimate tool when you need to find out which theme hook, or which template file to modify based on your design and layout needs.
It is a finicky module though, it doesn't work with the latest version of one of it's dependencies, simplehtmldom API, and when turned on it can break your layout.
Note that this module injects markers into the DOM to do its magic. This may cause some themes to behave erratically and less capable browsers may make it worse (especially IE)/. Enable it when needed, and disable it afterwards.
To ensure I install the correct branch of the modules, and to speed up enabling and disabling, I set up some aliases in my local/development computer's .bash_profile:
# Download simplehtmldom API 7.x-1.12 branch, then Theme Developer
alias develthemerdl='drush dl -y simplehtmldom-7.x-1.12 devel_themer'
# Enable simplehtmldom API 7.x-1.12, then Theme Developer
alias develthemeren='drush en -y simplehtmldom devel_themer'
# Disable Theme Developer, then simplehtmldom API 7.x-1.12
alias develthemerdis='drush dis -y devel_themer simplehtmldom'
# Uninstall Theme Developer, then simplehtmldom API 7.x-1.12
alias develthemerun='drush pm-uninstall devel_themer simplehtmldom'
With these aliases set up, I can install, activate, deactivate and uninstall in seconds. These two modules, and devel for that matter, have no place on a production site. Often, I don't even send Theme Developer to the repository/staging server.
Once enabled, go to the page you want to investigate, and check on the Themer info box in the bottom left:
Then in the top right you will see an instructions box:
Hovering over sections of the page will reveal outlines of the elements:
Clicking on them will reveal the hook or template you are looking for:
Those are the basics. My site's templates are as basic as they can be, so there aren't much in the screenshots, but on more complex sites, Theme Developer will show all the field, block, node, region, page and whatever templates you may have.
When you are ready deactivate and uninstall the modules, and you can go back to the theming mission you were on when we started this escapade.