Skip to content

Commit

Permalink
Merge pull request #10239 from jdalsem/list-no-results
Browse files Browse the repository at this point in the history
fix(views): no results listing output should show if empty item views
  • Loading branch information
jdalsem committed Sep 23, 2016
2 parents 6c851f7 + a3d4f8c commit cbec2c1
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, '');

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

Expand Down Expand Up @@ -72,7 +68,12 @@
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') {
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, '');

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

Expand Down Expand Up @@ -81,7 +77,12 @@
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') {
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 cbec2c1

Please sign in to comment.