My module provides a simple block which needs to contain an unordered list with some images. From a block function, I am returning a renderable array:
$block['content'] = array(
'list' => array(
'#theme' => 'item_list',
'#type' => 'ul',
'#attributes' => array('class' => 'foo1'),
'#items' => array(
/* ... what should go here? */
),
),
);
I would like to have some renderable arrays as items in the item list, but I seem to be unable to insert any arrays into the #items
array.
The Drupal 7 theme_item_list API docs says:
items: An array of items to be displayed in the list. If an item is a string, then it is used as is. If an item is an array, then the "data" element of the array is used as the contents of the list item. If an item is an array with a "children" element, those children are displayed in a nested list. All other elements are treated as attributes of the list item element.
I tried using both "data" and "children" elements, but I get either empty <li>
's or there is a word Array
inside them.
What is the proper way to do this? Is theme_item_list the right/up-to-date solution?
'#items' => array('data' => 'my data')
doesn't seem to really do anything more than'#items' => 'my data'
(look at the code for theme_item_list).'children'
is used specifically to create a nested list. I'm not sure why it's set up this way.