2

I would like to take advantage of the settings I can set under admin/structure/types/manage/node_type/display when i render my custom fields in node--node_type.tpl.php but using the following code I just get some sort of default display setting:

<?php 
  print render( field_view_field('node', $node, 'field_date', array('label' => 'hidden')) ); 
?>

This prints my date in the long format, but under /display I already set it to medium. Also I have already set the label as hidden under the display settings.

How can I use those settings and only override them if I want to? Or is field_view_field() not the right function?

2

The content array should already contain an element for each field with the display settings applied. You can just print that directly:

<?php print render($content['field_date']); ?>
1
  • That's the one. Fantastic. Thanks for the quick answer. – schwifty Jun 19 '13 at 18:52

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.