3

What is the difference between render($content['body']); and print $body[0]['value']; in node.tpl.php?

render($content['body']); seems to include all the fields while print $body[0]['value']; includes just the body field.

5

You kind of answered your own question. $content['body'] contains everything in a structure in which the render function can turn it into display. This includes all your fields.

print $body[0]['value'] simply prints the value of that one field bypassing any rendering functionality such as "weight".

Rendering is a fun thing in Drupal, especially when you get to Drupal 7. Think of what you're passing into "render" as instructions on how to output, whereas the value is simply... a string... a value.

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.