views:

37

answers:

2

Hi, I can apply a custom theme to a certain content type in Drupal by copying the node.tpl.php file and placing the name of my content type right after the "node" in the file name and appending an hyphen. Ok, the new name is: node-page_two_columns_images.tpl.php.

But that won't give me much flexibility if I am not able to edit the way each of the fields of my content type are rendered. If you get the node.tpl.php file, here is the line I am interested in:

<?php print $content ?>

I need to edit the way the elements in $content are rendered. Why? Basically because the title of the page needs to go between two of these elements... more or less like this:

<div id="field-1-of-my-content-type">[stuff1]</div>
<h1><?php print $title ?></h1>
<div id="field-2-of-my-content-type">[stuff2]</div>

Is there a template file I can create to replace the elements in this $content variable or do I need to write my own specific function?

Thank you!

+1  A: 

Instead of using $content, you can print out all the elements yourself, as they are available in the node template. That way you can arrange the title and CCK they way you want to.

Update:
The easiest way to theme a node with CCK fields is to use $field_[field_name]_rendered, it has the themed version of the CCK field. CCK creates that variable to make theming the node easier.

googletorp
Hum, thank you... Any tips on a webpage with information on that? If I print the exact name of my field as a variable, <strong><?php print $field_body2 ?></strong>, drupal returns the text "Array"
Marcos Buarque
You need to print arrays with a different function. print_r($var) works. I'm partial to installing the devel module then using dpm($var), the more structured and javascripted output is easier to read.
Grayside
+1  A: 

check out the content template module.

Al W
Thank you, I will give it a try!
Marcos Buarque