function theme_item_list

cis7 theme.inc theme_item_list($variables)
cle7 theme.inc theme_item_list($variables)
elmsmedia7 theme.inc theme_item_list($variables)
icor7 theme.inc theme_item_list($variables)
meedjum_blog7 theme.inc theme_item_list($variables)
mooc7 theme.inc theme_item_list($variables)

Returns HTML for a list or nested list of items.

Parameters

$variables: An associative array containing:

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

Related topics

4 calls to theme_item_list()
adaptivetheme_item_list in sites/all/themes/ulmus/adaptivetheme/at_core/inc/theme.inc
Returns HTML for a list or nested list of items.
aurora_item_list in sites/all/themes/ulmus/aurora/includes/theme.inc
Returns HTML for a list or nested list of items.
omega_item_list in sites/all/themes/ulmus/omega/omega/includes/omega.theme.inc
Implements hook_item_list().
theme_fctw_item_list in sites/all/modules/ulmus/field_collection_tabs_widget/field_collection_tabs_widget.module
Theme function for generating an item list.
90 theme calls to theme_item_list()
accessibility_tests_list_done in sites/all/modules/ulmus/accessibility/accessibility.admin.inc
Batch import finished callback.
advanced_help_get_tree in sites/all/modules/ulmus/advanced_help/advanced_help.module
Build a tree of advanced help topics.
advanced_help_view_topic in sites/all/modules/ulmus/advanced_help/advanced_help.module
Load and render a help topic.
aggregator_block_view in modules/aggregator/aggregator.module
Implements hook_block_view().
at_core_responsive_panels_form in sites/all/themes/ulmus/adaptivetheme/at_core/inc/forms/settings.responsivepanels.inc
@file Generate form elments for the Panel and Gpanel Reponsive Layout settings.

... See full list

103 string references to the theme hook from theme_item_list()

Note: this list is generated by looking for the string for this theme hook, so it may include some references that are not actually using this theme hook.

accessibility_tests_list_done in sites/all/modules/ulmus/accessibility/accessibility.admin.inc
Batch import finished callback.
advanced_help_get_tree in sites/all/modules/ulmus/advanced_help/advanced_help.module
Build a tree of advanced help topics.
advanced_help_index_page in sites/all/modules/ulmus/advanced_help/advanced_help.module
Page callback to view the advanced help topic index.
advanced_help_view_topic in sites/all/modules/ulmus/advanced_help/advanced_help.module
Load and render a help topic.
aggregator_block_view in modules/aggregator/aggregator.module
Implements hook_block_view().

... See full list

File

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

Code

function theme_item_list($variables) {
  $items = $variables['items'];
  $title = $variables['title'];
  $type = $variables['type'];
  $attributes = $variables['attributes'];

  // 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.
  $output = '<div class="item-list">';
  if (isset($title) && $title !== '') {
    $output .= '<h3>' . $title . '</h3>';
  }

  if (!empty($items)) {
    $output .= "<$type" . drupal_attributes($attributes) . '>';
    $num_items = count($items);
    $i = 0;
    foreach ($items as $item) {
      $attributes = array();
      $children = array();
      $data = '';
      $i++;
      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) {
        // Render nested list.
        $data .= theme_item_list(array('items' => $children, 'title' => NULL, 'type' => $type, 'attributes' => $attributes));
      }
      if ($i == 1) {
        $attributes['class'][] = 'first';
      }
      if ($i == $num_items) {
        $attributes['class'][] = 'last';
      }
      $output .= '<li' . drupal_attributes($attributes) . '>' . $data . "</li>\n";
    }
    $output .= "</$type>";
  }
  $output .= '</div>';
  return $output;
}