element * @uses $vars['item_class'] Additional CSS class for the
  • elements * @uses $vars['item_view'] Alternative view to render list items * @uses $vars['no_results'] Message to display if no results (string|Closure) */ $items = $vars['items']; $count = elgg_extract('count', $vars); $pagination = elgg_extract('pagination', $vars, true); $position = elgg_extract('position', $vars, 'after'); $no_results = elgg_extract('no_results', $vars, ''); if (!$items && $no_results) { if ($no_results instanceof Closure) { echo $no_results(); return; } echo "

    $no_results

    "; return; } if (!is_array($items) || count($items) == 0) { return; } $list_classes = ['elgg-list']; if (isset($vars['list_class'])) { $list_classes[] = $vars['list_class']; } $item_classes = ['elgg-item']; if (isset($vars['item_class'])) { $item_classes[] = $vars['item_class']; } $nav = ($pagination) ? elgg_view('navigation/pagination', $vars) : ''; $list_items = ''; foreach ($items as $item) { $item_view = elgg_view_list_item($item, $vars); if (!$item_view) { continue; } $li_attrs = ['class' => $item_classes]; if ($item instanceof \ElggEntity) { $guid = $item->getGUID(); $type = $item->getType(); $subtype = $item->getSubtype(); $li_attrs['id'] = "elgg-$type-$guid"; $li_attrs['class'][] = "elgg-item-$type"; if ($subtype) { $li_attrs['class'][] = "elgg-item-$type-$subtype"; } } else if (is_callable(array($item, 'getType'))) { $li_attrs['id'] = "item-{$item->getType()}-{$item->id}"; } $list_items .= elgg_format_element('li', $li_attrs, $item_view); } if ($position == 'before' || $position == 'both') { echo $nav; } echo elgg_format_element('ul', ['class' => $list_classes], $list_items); if ($position == 'after' || $position == 'both') { echo $nav; }