why render array used in drupal theming layer instead all theming functionality can be achieved by using print statements in templates files.Any analogy that explain use of render array in theming layer and how it interact with tpl.php files.please answer the question little bit in descriptive way because i am drupal newbie.

share|improve this question
1  
Try The Scary Render Array – Andy Sep 23 '12 at 15:40

1 Answer

A render array is a classic Drupal structured array that provides data (probably nested) along with hints as to how it should be rendered (properties, like #type).

render($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.

Nice documentation regarding Render Arrrays in Drupal 7 on Drupal.org

share|improve this answer
thanks mohit,but still i'm little bit confuse . Is render array contain key-value entries that is generated by node module only? or comments fields also included? – GILL Oct 16 '12 at 13:34

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

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