I am still new to Drupal.

I want to change the design of a specific content type, so i have been looking at node-*.tpl.php.

What i found out is, that all the content is in one variable called $content.
I want to move the different content fields around, for example in 2 columns, so i guess i need to split up the different content fields in $content.

What is the best practices to do this ? Should i use variables like [content][body][#value] to get access to one specific field ?
I guess, if i use this method, i have to add fields in node-*.tpl.php each time i add fields in the content type, so maybe this isnt a good solution ?

Comments

sujith7c’s picture

Here is my suggestion

if your theme name is mytheme, and your node type is mytype

you can write a small function in template.php in your theme directory

example

function mytheme_preprocess_page(&$vars) {
if (arg(0) == 'node' && is_numeric(arg(1))) {
$node = $vars['node'];
switch($node->type) {
case 'mytype':
if (!in_array("edit", arg())) {
$vars['template_files'] = array('customtemplate');
}
break;
}

}

then create 'customtemplate.tpl.php in your template folder, and do what you need .
if you installed devel module you can use dpm($node) function to inspect $node variable. it give you a better understanding of $node .

peturkirke’s picture

this answer seems very strange to me, and is very confusing ? and i dont understand the point with it

just_fixed_it’s picture

It's a very flexible mechanism for Drupal.

Read the docs, have a go, and I'm sure you'll find it suprisingly easy.

pontus_nilsson’s picture

For this use I would leave the node.tpl.php alone and only theme the node using css. Check your classes on the <body> element.

peturkirke’s picture

I have to admit im not an CSS expert, so i have only one question:

Is it possible to put the different content fields into 2 different columns only with CSS ?

Hari’s picture

Most likely. Try finding the ids and classes of the content using firebug add on for firefox.

http://www.addedbytes.com/cheat-sheets/css-cheat-sheet/

Hari.

peturkirke’s picture

Thanks for help. My knowledge about positioning and float left, was limited yesterday. But yesterday night i read a lot about CSS, and now my knowledge is much better, and i think i can solve this problem. :)