I've installed Drupal 6.x and think it's great. I've added some editors without problems and would now like to customize the pages that will be hosting the content from drupal. I started editing the template file (page.tpl.php) of one of the themes to customize it for my site. It seems as if I could continue to customize this one file and get my main page look just the way I want it. But, now my admin interface looks the same way and also any future pages I make will all have the same layout.

Is there a way to make one custom page to host the "story" content, another custom template page for the "page" content and yet another for the admin interface?

Comments

gbrussel’s picture

You can customize how each content type is displayed by creating a new node-type.tpl.php.

If I had a blog and wanted to customize it, I'd create a new file (by copying node.tpl.php and renaming) called node-blog.tpl.php, and make my modifications there.

WorldFallz’s picture

Is there a way to make one custom page to host the "story" content, another custom template page for the "page" content and yet another for the admin interface?

You bet-- assuming you're using a phptemplate based theme. There are many template suggestions automatically available for use and you can create new ones if you need to as well.

node.tpl.php files are available for content type by default (i.e. node-story.tpl.php, node-page.tpl.php, etc). For page.tpl.php templates you'll have to create it. Try the following in your template.php file:

<?php
function phptemplate_preprocess_page(&$vars) {
  if ($vars['node']->type){
    $vars['template_file'] = 'page-' . $vars['node']->type;
  }
}
?>

That should give you page-{content-type}.tpl.php files for all your content types.

For admin pages, just set a separate admin theme (admin/settings/admin).

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

abe’s picture

It does not seem to work on my drupal-5.12. I copied the function into template.php and my custom layout for the (also custom) content type is not displayed. Any thoughts?

I don't thint it matters... I am also using the 'basic' theme.

Thanks,

Abe

WorldFallz’s picture

This is d6 code-- for d5 code see Different page templates depending on node type.

===
"Give a man a fish and you feed him for a day. Teach a man to fish and you feed him for a lifetime." - Lao Tzu
"God helps those who help themselves." - Ben Franklin
"Search is your best friend." - Worldfallz

nleo’s picture

phptemplate_preprocess_page(&$vars) doesn't work when click "Post Comment". $vars['node'] not exists in this case. What can I do to use my page templates depends on node types for commenting?