I understand that a render array looks like this

#theme' => 'feed_icon',
        '#url' => 'rss.xml',
        '#title' => t('Syndicate'),

The first property is the theme type, the following properties are the properties which are unique to that theme.

My question is how do you chain together multiple render arrays in a single render array so that a programaticaly created block or page can have multiple render-able objects.
In the case ubove this would need to be changed to have multiple feed icons, another possible use case is a list of links.

On a side note
Is it possible to wrap individual theme items in divs (by using some sort of wrapper/ prefix and suffix code)

Comments

Jaypan’s picture

$some_page = array
(
  '#prefix' => '<div id="page_wrapper">',
  '#suffix' => '</div>',
  'item_one' => array
  (
    '#theme' =>  'some_theme',
    '#var1' => 'some_var',
  ),
  'item_two' => array
  (
    '#prefix' => '<div id="some_id">',
    '#suffix' => '</div>',
    'sub_element_one' => array
    (
      '#markup' => t('This is sub element one'),
    ),
    'sub_element_two' => array
    (
      '#markup' => t('This is sub element two'),
    ),
  ),
  'pager' => array
  (
    '#theme' => 'pager',
  ),
);

As you can see there are a few levels. You can go even deeper in levels if you want. Anything not prefixed with a # will be rendered. Anything prefixed with a # will be used for the rendering.