Skip to content

Commit

Permalink
fix(views): no results listing output should show if empty item views
Browse files Browse the repository at this point in the history
fixes #9917
  • Loading branch information
jdalsem committed Sep 23, 2016
1 parent fbf52cb commit a3d4f8c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
13 changes: 7 additions & 6 deletions views/default/page/components/gallery.php
Expand Up @@ -24,11 +24,7 @@
$no_results = elgg_extract('no_results', $vars, ''); $no_results = elgg_extract('no_results', $vars, '');


if (!$items && $no_results) { if (!$items && $no_results) {
if ($no_results instanceof Closure) { echo elgg_view('page/components/no_results', $vars);
echo $no_results();
return;
}
echo "<p class='elgg-no-results'>$no_results</p>";
return; return;
} }


Expand Down Expand Up @@ -72,7 +68,12 @@
echo $nav; echo $nav;
} }


echo elgg_format_element('ul', ['class' => $list_classes], $list_items); if (empty($list_items) && $no_results) {
// there are scenarios where item views do not output html. In those cases show the no results info
echo elgg_view('page/components/no_results', $vars);
} else {
echo elgg_format_element('ul', ['class' => $list_classes], $list_items);
}


if ($position == 'after' || $position == 'both') { if ($position == 'after' || $position == 'both') {
echo $nav; echo $nav;
Expand Down
13 changes: 7 additions & 6 deletions views/default/page/components/list.php
Expand Up @@ -26,11 +26,7 @@
$no_results = elgg_extract('no_results', $vars, ''); $no_results = elgg_extract('no_results', $vars, '');


if (!$items && $no_results) { if (!$items && $no_results) {
if ($no_results instanceof Closure) { echo elgg_view('page/components/no_results', $vars);
echo $no_results();
return;
}
echo "<p class='elgg-no-results'>$no_results</p>";
return; return;
} }


Expand Down Expand Up @@ -81,7 +77,12 @@
echo $nav; echo $nav;
} }


echo elgg_format_element('ul', ['class' => $list_classes], $list_items); if (empty($list_items) && $no_results) {
// there are scenarios where item views do not output html. In those cases show the no results info
echo elgg_view('page/components/no_results', $vars);
} else {
echo elgg_format_element('ul', ['class' => $list_classes], $list_items);
}


if ($position == 'after' || $position == 'both') { if ($position == 'after' || $position == 'both') {
echo $nav; echo $nav;
Expand Down
17 changes: 17 additions & 0 deletions views/default/page/components/no_results.php
@@ -0,0 +1,17 @@
<?php
/**
* No results view
*
* @uses $vars['no_results'] Message to display if no results (string|Closure)
*/
$no_results = elgg_extract('no_results', $vars);
if (empty($no_results)) {
return;
}

if ($no_results instanceof Closure) {
echo $no_results();
return;
}

echo "<p class='elgg-no-results'>$no_results</p>";

0 comments on commit a3d4f8c

Please sign in to comment.