You are here

function theme_item_list in Drupal 6

Same name and namespace in other branches
  1. 4 includes/theme.inc \theme_item_list()
  2. 5 includes/theme.inc \theme_item_list()
  3. 7 includes/theme.inc \theme_item_list()

Return a themed list of items.

Parameters

$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.

$title: The title of the list.

$type: The type of list to return (e.g. "ul", "ol")

$attributes: The attributes applied to the list element.

Return value

A string containing the list output.

Related topics

18 theme calls to theme_item_list()
aggregator_block in modules/aggregator/aggregator.module
Implementation of hook_block().
blog_page_last in modules/blog/blog.pages.inc
Menu callback; displays a Drupal page containing recent blog entries of all users.
blog_page_user in modules/blog/blog.pages.inc
Menu callback; displays a Drupal page containing recent blog entries of a given user.
book_render in modules/book/book.pages.inc
Menu callback; prints a listing of all books.
help_page in modules/help/help.admin.inc
Menu callback; prints a page listing general help for a module.

... See full list

File

includes/theme.inc, line 1536
The theme system, which controls the output of Drupal.

Code

function theme_item_list($items = array(), $title = NULL, $type = 'ul', $attributes = NULL) {
  $output = '<div class="item-list">';
  if (isset($title)) {
    $output .= '<h3>' . $title . '</h3>';
  }
  if (!empty($items)) {
    $output .= "<{$type}" . drupal_attributes($attributes) . '>';
    $num_items = count($items);
    foreach ($items as $i => $item) {
      $attributes = array();
      $children = array();
      if (is_array($item)) {
        foreach ($item as $key => $value) {
          if ($key == 'data') {
            $data = $value;
          }
          elseif ($key == 'children') {
            $children = $value;
          }
          else {
            $attributes[$key] = $value;
          }
        }
      }
      else {
        $data = $item;
      }
      if (count($children) > 0) {
        $data .= theme_item_list($children, NULL, $type, $attributes);

        // Render nested list
      }
      if ($i == 0) {
        $attributes['class'] = empty($attributes['class']) ? 'first' : $attributes['class'] . ' first';
      }
      if ($i == $num_items - 1) {
        $attributes['class'] = empty($attributes['class']) ? 'last' : $attributes['class'] . ' last';
      }
      $output .= '<li' . drupal_attributes($attributes) . '>' . $data . "</li>\n";
    }
    $output .= "</{$type}>";
  }
  $output .= '</div>';
  return $output;
}