8 common.inc render(&$element)
7 common.inc render(&$element)

Renders an element.

This function renders an element using drupal_render(). The top level element is shown with show() before rendering, so it will always be rendered even if hide() had been previously used on it.


$element: The element to be rendered.

Return value

The rendered element.

See also




23 calls to render()
block.tpl.php in modules/block/block.tpl.php
Default theme implementation to display a block.
book-all-books-block.tpl.php in modules/book/book-all-books-block.tpl.php
Default theme implementation for rendering book outlines within a block.
comment-wrapper.tpl.php in modules/comment/comment-wrapper.tpl.php
Default theme implementation to provide an HTML container for comments.
comment-wrapper.tpl.php in themes/bartik/templates/comment-wrapper.tpl.php
Bartik's theme implementation to provide an HTML container for comments.
comment.tpl.php in themes/garland/comment.tpl.php

... See full list

4 string references to 'render'
hook_batch_alter in modules/system/system.api.php
Alter batch information before a batch is processed.
overlay_batch_alter in modules/overlay/overlay.module
Implements hook_batch_alter().
overlay_drupal_goto_alter in modules/overlay/overlay.module
Implements hook_drupal_goto_alter().
overlay_init in modules/overlay/overlay.module
Implements hook_init().


includes/common.inc, line 6100
Common functions that many Drupal modules will need to reference.


function render(&$element) {
  if (is_array($element)) {
    return drupal_render($element);
  else {
    // Safe-guard for inappropriate use of render() on flat variables: return
    // the variable as-is.
    return $element;


I created this for the NineSixty theme but I think this can be very useful to all themers. Takes a simple selector and searches the render array and prints it out.


Read more here: Render Arrays in Drupal 7 (Documentation)

There seems to be a problem with this. Bartik, Garland and other bundled themes blow up on render if it is called from theme('page', $output) where $output is some plain HTML you have to craft yourself (eg. when you have to IFRAME a page into a Drupal site). PHP throws an "Only variables can be passed by reference" fatal error and the execution will not reach inside the function, to the conditional in the first place. A workaround is to create a surrogate form with a single #markup inside but is this working as designed?

I have noticed in D7.8 that if you render an empty region. the region didn't remain empty anymore. render populates the #printed true and #children with an empty array.
I haven't found anything regarding this in any documentation


You may chose to render form elements individually in your custom theme. In that case you need to remember to add the following elements to your output:

$form['form_build_id'], $form['form_id'] and $form['form_token']

If you do not include them Drupal will ignore the form submission (and your submit handler(s).

more info here.

why render function hides img tags?