For example, how do I make http://www.sosodef.org/drupal have a different layout than http://www.sosodef.org/drupal/node/3. I'd like to have a different stylesheet and .tpl.php so that I can individually customize each page.

Can anyone advise?

Thanks

Comments

nathanjo’s picture

You can create page-front.tpl.ph to customize your frontpage only. and some page-node-x.tpl.php

start here : http://drupal.org/node/104316

TooFatToFish’s picture

Thanks bro. I renamed it to page-front.tpl.php, but now it removed all the styling. How do I fix that?

marquardt’s picture

node-front.tpl.php only styles the front page. If you have removed node.tpl.php, there's nothing that styles the other pages. You need both files (and then modify them in different ways...)

TooFatToFish’s picture

I thought it was page-front.tpl.php? I changed page.tpl.php to page-front.tpl.php

nevets’s picture

You still need page.tpl.php.

cincy_kid’s picture

In your theme folder (sites/all/themes/YOUR_THEME), you need to have the main files like page.tpl.php, node.tpl.php and any other main .tpl.php file where you plan on creating a new one (like page-front.tpl.php).

There are a lot of neat templates you can create based on views (views-view--taxonomy-term.tpl.php), content types (node-YOUR_CONTENT_TYPE.tpl.php), etc. by creating them in your theme folder.

good luck!

TooFatToFish’s picture

Thanks for the help guys. Please note that I'm coming to Drupal from Wordpress that's why I'm a bit confused with the terms, etc.

If page-front.tpl.php will control the front page, then what do I do with page.tpl.php?

cincy_kid’s picture

you just need to have that file in your theme folder or the page-front wont work

TooFatToFish’s picture

Oh ok, cool.

I want my node stories to have a different layout from the home page. So basically all I have to do to create one for my stories is create a file called node-story.tpl.php and Drupal will automatically recognize it? If so, how do I make that specific file call a stylesheet that's different from the one that the home page is using? Or do I just put everything in one stylesheet?

cincy_kid’s picture

correct, and make sure you also have the file node.tpl.php in your theme directory as well.

as far as the style sheet I have always used one (usually YOUR_THEME.css in your theme directory)

TooFatToFish’s picture

Thanks so much for the help, cincy.

Is it possible to copy all the code I have in page.tpl.php and put it in node-story.tpl.php so that it has the same format and I customize what I want?

I tried doing this, but the header and everything overlaps. I want to make it so that I can customize the whole page of the node story.

TooFatToFish’s picture

Help ... please!

marquardt’s picture

When generating the html output for a node, Drupal for a file named node-.tpl.php file in the theme folder; the node-front.tpl.php is just a special case of this rule for the front page. If it finds such a file, it's using that one to render your node. If it doesn't find this file, it's falling back to node.tpl.php and uses that. If it doesn't find it, it can't render the node - which is what happened to you in the first place. So you'll always want to have a generic node.tpl.php in your theme to be sure that every content can at least be displayed somehow.

The usual workflow probably is to start with a copy of your node.tpl.php and modify it according to your needs for that particular content type. And you do that for every content type you want to render differently from the default, which again is provided by node.tpl.php.

Now, Drupal offers actually more than that; you can (for example) even address individual nodes via template files if you want to. You can also render bits and pieces of every page differently by providing the corresponding template files. The usual work flow here is that you identify which template file is responsible for the output that Drupal generates, and then create a copy of that template file as part of your theme (and modify it so that it meets your needs). In any case, template files in your theme will always override / take precedence over the default template files coming as part of Drupal core or contributed modules. Which template files are read and in which order (in case there are there several ones, like multiple templates for rendering an individual node - that was the starting point of this thread) is based on naming conventions. These are documented in the Drupal 6 Theme Guide, which is really a great resource if you want or need to dig that deep. In general, though, the more specific file names are tried first.

The system might sound a bit complicated at first. But then, it also offers tremendous flexibility. And once you understand the naming conventions, it's actually pretty straightforward to get what you want.

jadenoel’s picture

So if I wanted to change the page layout (strip out the left and right sidebars) based on the content type, where said content type is named "handbook", which template file do I make a copy of to modify, and how do I name it?

Thanks,

Jade

miasmo’s picture

You may have figured something out already, but...

I had the same issue and I figured something out. I have a fixed two column layout (Zen subtheme) with main content on the left and a sidebar on the right. My problem was that with the right sidebar, my calendar pages were too scrunched up. I went to Administer » Site building » Blocks, and for every block I had in the right sidebar, I clicked "configure." Under "Page specific visibility settings" at the bottom of the page, I selected "Show on every page except the listed pages" and listed the pages that I didn't want to contain the sidebar. With the sidebar blocks gone from the calendar pages, the calendar expanded to an appropriate size taking up some of the space that had been the sidebar. I would not have expected this to work since it is a fixed layout. I did not have to mess with any template files or anything like that.

I hope this helps.