This is a step by step instruction with code on how to theme your Drupal node-custom.tpl.php files. Theming a Node in Drupal is the number one way to set your Drupal site apart.

If you understand basic HTML, CSS, and PHP then you are already most of the way there, if not, then try to follow what I'm going to say.

I first stumbled across an amazing piece of code by watching a podcast from Mustardseed Media Inc. I'm going to just expand on what he said and go into a little more detail here and there. I would recommend watching a few more of his podcasts as he does a really good job showing you how to do basic Drupal things.

First make a dummy node entry for the type that you will be modifying, we will use it later.

Then make a new node template for the node you are trying to custom theme. This is done in two ways:

  1. Copy the existing node.tpl.php file (if you only want to move a few things around) and rename it to node-custom.tpl.php, the "custom" part is the machine readable name you gave your node.
    For example: a blog entry would be node-blog.tpl.php *for Drupal 7 it would be node--blog.tpl.php (see update below)
  2. The other way is to simply make a new text file on your computer and name it node.tpl.php, this will give you a completely blank canvas to work with.

Once you have your new file made, put this piece of code at the bottom or if you started new then simply paste this code into your node-custom.tpl.php:

<?php print_r($node) ?>

Either just save your file or upload it to your ftp, depending on how you are working on your site.
Refresh your browser on the dummy node entry you made earlier. Notice now that after your content a bunch of other stuff now shows up. That is what we will be referencing later.

To use the code that is displayed on your node entry properly you must understand what it is doing.
These are php functions that we will call to our template and then manipulate to our hearts desire. Lets take a simple piece to start out with. I've set up a demo node with a node-demo.tpl.php you can find HERE. In the node-demo.tpl.php file, all I have printed is

<?php print_r($node) ?>

The text in the [brackets] are the functions that we are going to be using.
Starting off with something simple:

<?php print $node->content ?>

I want you to notice a few things here all the php coding we will be doing will all include:

<?php print ?>

We are simply printing the desired functions. The next part $node is referencing that we are working with a node type. and finally notice that the first level of the function isn't in [brackets]. If you use the rest of the function they will need to be enclosed in [brackets] like this:

<?php print $node->content ['body']['#value']?>

Make sure you use 'apostrophes' around the text in the [brackets], unless it is a number.

To print the content that you want. First, find the field that you want and then find the appropriate children or layers below that field until you get to the actual text, image, or other content. For example if you look again at the demo page HERE.

If I wanted to print the custom cck text field I made for the node. I first find the [field_custom], that is the machine readable name I made when setting up the cck field for the node. Note that there are actually two of these, you want to find the one that is not under the [content]. Then I find either the array above the final function or the final function itself. In this case I find the array [0]. Then I find the final function [value].

Now you put the php code together like this:

<?php print $node->field_custom[0]['value'] ?>

Now that you can print the functions you want, you can simply re-order them to suite your needs or change the css to fit your needs.

You can customize the style.css file also found in your theme's folder.
For example:
If you want a 1px black solid border around your content you make a new id in your style.css that looks something like this:

#contentbox {
    border: 1px solid #000;
    }

And then on your node-custom.tpl.php put this:

<div id="contentbox">
   anything you want in this div goes here
</div>

Update your online or offline files and see the change. *Make sure to clear your cache if you don't see any changes (thanks Robert Dickert)

These are the basics for customizing a node from the php to the css. With this knowledge go out and make great sites that look great, function better, and fit you specific needs not the default needs of all Drupal sites.

*Update for Drupal 7 -
Quote from Robert Dickert in the comment section comment section
"If you are using Drupal 7, you now need to name your file node--custom.tpl.php instead of node-custom.tpl.php (look carefully: there are 2 dashes instead of one)." Thanks Robert! I was getting around to updating this eventually


Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/rustic/public_html/hankpalan/sites/all/modules/twitter/twitter.inc:438 Stack trace: #0 /home/rustic/public_html/hankpalan/sites/all/modules/twitter/twitter.inc(438): SimpleXMLElement->__construct('') #1 /home/rustic/public_html/hankpalan/sites/all/modules/twitter/twitter.inc(101): _twitter_convert_xml_to_array(NULL) #2 /home/rustic/public_html/hankpalan/sites/all/modules/twitter/twitter.module(122): twitter_fetch_timeline('hankpalan') #3 [internal function]: twitter_cron() #4 /home/rustic/public_html/hankpalan/includes/module.inc(483): call_user_func_array('twitter_cron', Array) #5 /home/rustic/public_html/hankpalan/sites/all/modules/poormanscron/poormanscron.module(61): module_invoke_all('cron') #6 [internal function]: poormanscron_exit() #7 /home/rustic/public_html/hankpalan/includes/module.inc(483): call_user_func_array('poormanscron_ex...', Array) #8 /home/rustic/public_html/hankpalan/includes/common.inc(1625): module in /home/rustic/public_html/hankpalan/sites/all/modules/twitter/twitter.inc on line 438