Elgg  Version 3.0
list.php
Go to the documentation of this file.
1 <?php
2 
25 $pagination = elgg_extract('pagination', $vars, true);
26 $position = elgg_extract('position', $vars, 'after');
27 $no_results = elgg_extract('no_results', $vars, '');
28 
29 if ($no_results === true) {
30  $vars['no_results'] = elgg_echo('notfound');
31 }
32 
33 if (!$items && $no_results) {
34  echo elgg_view('page/components/no_results', $vars);
35  return;
36 }
37 
38 if (!is_array($items) || count($items) == 0) {
39  return;
40 }
41 
42 $list_classes = elgg_extract_class($vars, 'elgg-list', 'list_class');
43 
44 $list_item_view = elgg_extract('list_item_view', $vars);
46  $list_item_view = 'page/components/list/item';
47 }
48 
49 $nav = ($pagination) ? elgg_view('navigation/pagination', $vars) : '';
50 
51 $index = 0;
53 foreach ($items as $item) {
54  $item_view_vars = $vars;
55  $item_view_vars['list_item_index'] = $index;
56  $item_view = elgg_view_list_item($item, $item_view_vars);
57  if (!$item_view) {
58  continue;
59  }
60 
61  $list_item_vars = $vars;
62  $list_item_vars['content'] = $item_view;
63  $list_item_vars['item'] = $item;
64 
65  $list_items .= elgg_view($list_item_view, $list_item_vars);
66 
67  $index++;
68 }
69 
70 if ($position == 'before' || $position == 'both') {
71  echo $nav;
72 }
73 
74 if (empty($list_items) && $no_results) {
75  // there are scenarios where item views do not output html. In those cases show the no results info
76  echo elgg_view('page/components/no_results', $vars);
77 } else {
79 }
80 
81 if ($position == 'after' || $position == 'both') {
82  echo $nav;
83 }
$no_results
Definition: list.php:27
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
Definition: views.php:205
$position
Definition: list.php:26
$list_items
Definition: list.php:52
if($no_results===true) if(!$items &&$no_results) if(!is_array($items)||count($items)==0) $list_classes
Definition: list.php:42
if(!$items) $item
Definition: delete.php:13
if(empty($list_item_view)||!elgg_view_exists($list_item_view)) $nav
Definition: list.php:49
$count
Definition: list.php:24
elgg_echo($message_key, array $args=[], $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg_extract_class(array $array, $existing=[], $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:1153
elgg_view_list_item($item, array $vars=[])
View an item in a list.
Definition: views.php:1523
$list_item_view
Definition: list.php:44
$items
Definition: list.php:23
elgg_format_element($tag_name, array $attributes=[], $text= '', array $options=[])
Format an HTML element.
Definition: output.php:168
elgg echo
Translates a string.
Definition: languages.js:43
elgg_extract($key, $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1131
$pagination
Definition: list.php:25
$vars['type']
Definition: save.php:11
if($item->getSelected()) $item_view
Definition: item.php:59
elgg_view($view, $vars=[], $viewtype= '')
Return a parsed view.
Definition: views.php:246
$index
Definition: list.php:51