How does Drupal render 'render elements':

$account->content['example'] = array( {renderable array information on the t('Content')} ); (#1)

$account->content['example']['output'] = array( {renderable array information on the $content} ) (#2)

Where does drupal pass render elements to 'drupal_render()'?

Below is the entire hook function that contains the two render elements (#1), and (#2).

- - -

function example_user_view($account, $build_mode) {
  if (!user_access('view content creation permissions')) {
    return;
  }

  $node_types = node_permissions_get_configured_types();
  if (empty($node_types) {
    return;
  }

  $list = array();
  foreach ($node_types as $type) {
    if (user_access('create' . $type . ' content', $account)) {
      $list[] = check_plain(node_type_get_name($type));
    }
  }

  if (!empty($list)) {
    $variables = array (
      'items' => $list,
    );
  }
  $content = theme('item_list', $variables);
  if (!isset($account->content['example'])) {
    $account->content['example'] = array();
  }
  $account->content['example'] += array (
    '#type' => 'user_profile_category',
    '#attributes' => array('class' => array('user-member')),
    '#weight' => 5,
    '#title' => t('Content'),
  );
  $account->content['example']['output'] = array (
    '#type' => 'user_profile_item',
    '#title' => t('Content creation permissions'),
    '#markup' => $content,
    '#attributes' => array('class' => array('content-creation')),
  );
}

Comments

jmm42’s picture

'user_build_content()' invokes 'example_user_view()':

module_invoke_all('user_view', $account, $view_mode, $langcode);
- http://api.drupal.org/api/drupal/modules!user!user.module/function/user_...

But, after drupal modifies the '$account' object - within 'example_user_view()' - somewhere down the road, Drupal applies 'drupal_render()' on the two render elements. Could someone tell me what file / function handles this rendering process?

jmm42’s picture

I was in IRC just a moment ago, and determined my solution:

[me]: i just don't know how things are rendered
[me]: i don't see where my render elements are being passed to drupal_render()
[me]: perhaps, it's within the page.tpl.php, when i render($page['my_region'])?
[me]: and the render elements are contained within $page['my_region']

[timplunkett]: correct
[timplunkett]: and render calls drupal_render, and that is called recursively all the way down
[timplunkett]: so, render($page['content']) is the call