Why doesn't drupal_render work, but render does? I've a piece of code what is rendering a custom table (see var_dump below) what is shown on for specific states of the node. The data of the table is for both states the same.

array(1) {
  [0]=&gt;
  array(5) {
    ["#theme"]=&gt;
    string(5) "table"
    ["#header"]=&gt;
    array(2) {
      [0]=&gt;
      string(4) "test"
      [1]=&gt;
      string(9) "geen test"
    }
    ["#rows"]=&gt;
    array(2) {
      [0]=&gt;
      array(2) {
        [1]=&gt;
        string(6) "e1a1r1"
        [2]=&gt;
        string(6) "e1a2r1"
      }
      [1]=&gt;
      array(2) {
        [1]=&gt;
        string(6) "e1a1r2"
        [2]=&gt;
        string(6) "e1a2r2"
      }
    }
    ["#prefix"]=&gt;
    string(38) "&lt;h3&gt;Table&lt;/h3&gt;"
    ["#attributes"]=&gt;
    array(1) {
      ["class"]=&gt;
      array(1) {
        [0]=&gt;
        string(15) "previous-scheme"
      }
    }
  }
}


The custom states of the node are determined by a condition what prints one of the following gathered variables.

For the variable at the line below works with both drupal_render and render.

$kickoff_deadline .= '&lt;h2&gt;Between kickoff and deadline&lt;/h2&gt;'.drupal_render($table);


For the variable at the line below only works with render, without it wont show anything.

$after_deadline .= '&lt;h2&gt;After the deadline&lt;/h2&gt;'.render($table);


So what is happening? Why doesn't drupal_render work for a similar printed variable what does work?
Once you've done this:

$kickoff_deadline .= '&lt;h2&gt;Between kickoff and deadline&lt;/h2&gt;'.drupal_render($table);


The render array is marked as #printed, and won't be rendered again. So this

$after_deadline .= '&lt;h2&gt;After the deadline&lt;/h2&gt;' . drupal_render($table);


Will do nothing.

If you take a look at the code for render():

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


You can see it runs show($element);, making it available for rendering again. Which is why this works:

$after_deadline .= '&lt;h2&gt;After the deadline&lt;/h2&gt;'.render($table);