This is really really easy in Drupal 7: just use field_view_field or field_view_value. Choose the latter if you want to re-render a particular field value, or the former if you want to re-render the whole field (label and all values).

However, I couldn't figure out how to do this in Drupal 6. I resorted to implementing hook_nodeapi and changing the node content before it was rendered. This approach cannot be implemented from the theme, though, I'm looking for a theme solution.


In template_preprocess_node($vars), you can do:


and then all the fields of the node are available to you, and a quick

drupal_set_message('<pre>' . print_r($node,true) . '</pre>');

will show them to you. So if you had a text field called field_description you can access it via:


and you can then modify to your heart's content, eg:

$node->field_description[0]['value']='What I really wanted to say was....';

and then at the end:


sets it on its way.

  • That's not what I asked. I want to prepare the field, change some parameters and pass it through drupal_render(). And anyway, changing $vars['node'] would probably be useless since node.tpl.php prints $vars['content']. – Capi Etheriel Mar 20 '12 at 14:50
  • D'oh. You're right. But I've long stopped using $content in my node.tpl.php's for this and a whole other raft of reasons. But, you can cp content-field.tpl.php out of cck's directory and then cp it again to content-field-FIELDNAME.tpl.php and modify that to redo that field, and that will make it into $content. – Jimajamma Mar 20 '12 at 15:36
  • Yes, but it doesn't re-render the field items. field.tpl.php is just the wrapper. – Capi Etheriel Mar 21 '12 at 3:05
  • Why can't you change the <?php print $item['view'] ?> in there to whatever you need to render field how you want it rendered? You have $item['value'] or $item['nid'] etc so you have the raw information to work with to do whatever... or am I totally missing the point here? – Jimajamma Mar 21 '12 at 3:51
  • that is precisely what i'm looking for. The $item['value'] is not a renderable array, though, it's just the raw value (or a filtered value). What I want is to build the renderable array (with its '#theme' and '#formatter' items). – Capi Etheriel Mar 22 '12 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.