I have a function which returns a facebook wall feed. The data comes back fine but the point i'm having an issue with is combining the list children with the list array.

I start out by defining the list without children.

   $row = array(
    'item_list' => array(
      '#theme' => 'item_list',
      '#attributes' => array(
        'class' => array('wall-post-list')

After that i jump in to a foreach loop which i'll omit for clarity since it's large. First i create a container which will be inside the li of the list and then stuff that container with children like i did with 'account_link' which will be rendered as #markup FAPI elements.

     $list_items[$interation]['data'] = array(
      '#theme' => 'container',
      '#attributes' => array(
        'id' => array($post['id']),
        'class' => array('wall-post-content', $post['type']),
      'account_link' => array(
        '#markup' => l('<img class="user" src="http://graph.facebook.com/'. $post['from']['id'] . '/picture" />','http://facebook.com/' . $post['from']['id'], array(
          'attributes' => array(
            'class' => array('picture'),
            'target' => '_blank',
          'html' => TRUE,

So after building up what this list item is going to have in it I take the $list_items and stuff them into $row['#items']. And now this is where my issue is. The array looks perfect almost to perfect... And when it renders to the page i get


Is there some issue with my approach? or does theme_item_list not render out the children of a li and if so how can I get this to render recursively through the whole array?

Full function code here http://pastebin.com/dr3b4CTX

Correction: seems i was using #theme rather than #type in this situation.

1 Answer 1


I think what you are expecting is logical. But from the definition of theme_item_list() you can see that it expects value of the data key to be just HTML and hence prints it as it is. I could be wrong here and there is probably a hook_preprocess_* somewhere that pre-renders each item of the list.

Either way, an approach that should work is rendering your item before adding it to the list by calling drupal_render() yourself.

// .. your code .. //
$container_elem = array('#type' => 'container' ... );
$render = drupal_render($container_elem);
$row['item_list']['#items'][] = $render;
// .. your code .. //
  • I had tried that near the end of the function after the foreach loop. I had something along the lines of this around line 660 $rows = $row['item_list']; foreach($list_items as $list_item) { $rows['#items'][]['data'] = drupal_render($list_item['data']); }
    – Chad Payne
    Dec 20, 2012 at 17:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.