Elgg  Version 6.1
section.php
Go to the documentation of this file.
1 <?php
14 $items = elgg_extract('items', $vars, []);
15 if (empty($items) || !is_array($items)) {
16  return;
17 }
18 
19 unset($vars['items']);
20 
21 $headers = elgg_extract('show_section_headers', $vars, false);
22 unset($vars['show_section_headers']);
23 
24 $item_class = elgg_extract_class($vars, [], 'item_class');
25 unset($vars['item_class']);
26 
28 unset($vars['name']);
29 
30 $section = elgg_extract('section', $vars);
31 unset($vars['section']);
32 $vars['data-menu-section'] = $section;
33 
34 if ($headers) {
35  echo elgg_format_element(elgg_extract('section_header_tag_name', $vars, 'div'), [
36  'class' => 'elgg-menu-section-header',
37  ], elgg_echo("menu:$name:header:$section"));
38 }
39 
40 $lis = [];
41 foreach ($items as $menu_item) {
42  $item = elgg_view('navigation/menu/elements/item', [
43  'item' => $menu_item,
44  'item_class' => $item_class,
45  ]);
46 
47  if (empty($item)) {
48  continue;
49  }
50 
51  $lis[] = $item;
52 }
53 
54 if (empty($lis)) {
55  return;
56 }
57 
58 echo elgg_format_element('ul', $vars, implode(PHP_EOL, $lis));
if(!$items) $item
Definition: delete.php:13
elgg_echo(string $message_key, array $args=[], string $language= '')
Elgg language module Functions to manage language and translations.
Definition: languages.php:17
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:256
elgg_view(string $view, array $vars=[], string $viewtype= '')
Return a parsed view.
Definition: views.php:156
elgg_format_element(string $tag_name, array $attributes=[], string $text= '', array $options=[])
Format an HTML element.
Definition: output.php:145
elgg_extract_class(array $array, array|string $existing=[], string $extract_key= 'class')
Extract class names from an array, optionally merging into a preexisting set.
Definition: elgglib.php:279