Once you have preprocessed your variables in theme_preprocess_node()
you can print them in node.tpl.php
The best practices would imply to declare one node.tpl.php per content type like this : node--my-content-type.tpl.php
replacing my-content-type
by the name of your own content.
In theme_preprocess_node()
the best way to get the value of a field would be like this :
In template.php
the first function is only here so you can have one preprocess function per content type.
/**
* Override or insert variables into the node templates.
*
* @param $vars
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("node" in this case.)
*/
function mytheme_preprocess_node(&$vars, $hook) {
// Optionally, run node-type-specific preprocess functions, like
// mytheme_preprocess_node_page() or mytheme_preprocess_node_story().
$function = __FUNCTION__ . '_' . $vars['node']->type;
if (function_exists($function)) {
$function($vars, $hook);
}
}
Then you can declare your function for your content type and get the value of your fields with field_get_items()
and field_view_value()
in order to only get the value and not all the divs all around the field value.
/**
* Override or insert variables into the node templates.
*
* @param $vars
* An array of variables to pass to the theme template.
* @param $hook
* The name of the template being rendered ("node" in this case.)
*/
function mytheme_preprocess_node_my_content_type(&$vars, $hook) {
$node = &$vars['node'];
$first_name = field_get_items('node', $node, 'field_first_name');
$last_name = field_get_items('node', $node, 'field_last_name');
$vars['first_name'] = field_view_value('node', $node, 'field_first_name', $first_name[0]);
$vars['first_name'] = field_view_value('node', $node, 'field_last_name', $last_name[0]);
}
and then in your node--my-content-type.tpl.php
you can print your variable like this :
<?php print render($first_name); ?> <?php print render($last_name); ?>