page-content-type.tpl.php separate template for content type
You've probably created custom templates for your nodes more than once, by overriding them with node-content-type.tpl.php
.
Sometimes that’s enough, but other times you may need to define a specific page template for a content type. Unfortunately, in Drupal 6, this can’t be done without adding extra code. To enable custom templates like page-content-type.tpl.php
, add the following code to your template.php
file:
function phptemplate_preprocess_page(&$vars) { if (isset($vars['node'])) { $vars['template_files'][] = 'page-' . str_replace('_', '-', $vars['node']->type); } }
Now you can create custom templates for your content types. For example, page-news.tpl.php
(where news
is the machine name of the news content type).
It’s also possible in Drupal to override taxonomy term output templates by adding the following function to template.php
:
function phptemplate_preprocess_node(&$vars) { if (arg(0) == 'taxonomy') { $suggestions = array( 'node-taxonomy' ); $vars['template_files'] = array_merge($vars['template_files'], $suggestions); } }
After that, you can override the template by placing a node-taxonomy.tpl.php
file in your current theme folder.