8.5.x common.inc render(&$element)
8.0.x common.inc render(&$element)
8.1.x common.inc render(&$element)
8.2.x common.inc render(&$element)
8.3.x common.inc render(&$element)
8.4.x common.inc render(&$element)
8.6.x common.inc render(&$element)
7.x 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 modules/comment/comment.tpl.php
Default theme implementation for comments.

... See full list


includes/common.inc, line 6156
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;


dvessel’s picture

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.


Sutharsan’s picture

joshmiller’s picture

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

djg_tram’s picture

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?

jibran’s picture

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

print render(page['sidebar_first']);
kwesistewart’s picture

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.

a77icu5’s picture

why render function hides img tags?