Returns HTML for a list or nested list of items.
$variables: An associative array containing:
function theme_item_list($variables) {
$items = $variables['items'];
$title = (string) $variables['title'];
// @todo 'type' clashes with '#type'. Rename to 'tag'.
$type = $variables['type'];
$list_attributes = $variables['attributes'];
$output = '';
if ($items) {
$output .= '<' . $type . new Attribute($list_attributes) . '>';
$num_items = count($items);
$i = 0;
foreach ($items as &$item) {
$i++;
$attributes = array();
if (is_array($item)) {
if (isset($item['#wrapper_attributes'])) {
$attributes = $item['#wrapper_attributes'];
}
$item = drupal_render($item);
}
$attributes['class'][] = $i % 2 ? 'odd' : 'even';
if ($i == 1) {
$attributes['class'][] = 'first';
}
if ($i == $num_items) {
$attributes['class'][] = 'last';
}
$output .= '<li' . new Attribute($attributes) . '>' . $item . '</li>';
}
$output .= "</{$type}>";
}
// Only output the list container and title, if there are any list items.
// Check to see whether the block title exists before adding a header.
// Empty headers are not semantic and present accessibility challenges.
if ($output !== '') {
if ($title !== '') {
$title = '<h3>' . $title . '</h3>';
}
$output = '<div class="item-list">' . $title . $output . '</div>';
}
return $output;
}