Different page templates for different content types
Key words and phrases
Different page templates for different content types page.tpl for content type drupal 5 5.x themingTags
Description
Once upon a time there was a drupal themer working on a dark and stormy night, he sat there wondering how to make different page templates for certain content types on his site. He thought about how the drupal template system seems to be missing this for some reason... Suddenly, he had a vision! Like a ray of light bringing, hope and happiness down from the heavens!! oh yes!!
Resolution
<?php
// Add additional template suggestions
function _phptemplate_variables($hook, $vars) {
switch ($hook) {
case 'page':
// Add page template suggestions based on node type, if we aren't editing the node.
if ($vars['node'] && arg(2) != 'edit') {
$vars['template_files'][] = 'page-'. $vars['node']->type;
}
break;
}
return $vars;
}
?>This means if you have a content type called event and you want it to have a custom page layout, just copy page.tpl.php to page-event.tpl.php.
got it?
just dump the code into template.php, then make a page template called page-[CONTENT TYPE].tpl.php
and drupal will use that instead

Hi,
Can we have different node templates based on the node types. Is this possible in Drupal?
As of Drupal 5, just copy your
node.tpl.phpfile to whichevernode-CONTENT_TYPE.tpl.phpand that template file will be used for theming nodes of that type.For example,
node-event.tpl.php.I could not make this work for version 6.4. Should it work?
It works.
I used a Zen subtheme and had to use the right function name to override.
Thank you.
That means a lot, even though we weren't able to test 6 for you ourselves. Glad it works!
It doesnt work for me hope you help me
I get an error:
Fatal error: Cannot redeclare _phptemplate_variables() (previously declared in /home/content/xxx/themes/celju/template.php:21) in /home/content/xxx/themes/celju/template.php on line 81
I am using 6.3.
Any ideas? Thanks.
Hi Matt, is the theme you are using celju? If so just find where in template.php _phptemplate_variables() is defined and add the code there, though this is a post for Drupal 5.
Yes, celju and yeah I had to take out the other code.
I couldn't get your snippet to work in D6 with a Zen subtheme.
This method worked though.