Today, we were trying to theme a specific node type and ran into a few gotchas along the way.
Start by checking out the API documentation:
Working with template suggestions
Core templates and suggestions
First gotcha: The node type we were working with had an underscore in the name (for example: my_content_type). We assumed the node template file should be named: node-my-content-type.tpl.php. After some frustration, we realized the template file should be: node-mycontenttype.tpl.php.
We were able to figure this out by using the Devel module. This module implements the "Themer Information" functionality which is very useful when creating your theme. If you click on the div that contains your specific node type, it will provide you with information to determine how to override your themable output. In this case, the section "Candidate template files" pointed us in the right direction:
node-mycontenttype.tpl.php < node.tpl.phpSecond gotcha: We copied the node.tpl.php from /modules/node/ into our theme directory and renamed it to: node-mycontenttype.tpl.php. We then put this line in the template.php file to reset the theme registry:
drupal_rebuild_theme_registry();At this point, we expected our new theme file to be used and it was not. After some tinkering with hook_theme() and the theme registry, we realized node.tpl.php had to be in the theme directory as well. [to be continued...]




















