1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-09 16:26:59 +02:00
This commit is contained in:
Ryan Cramer
2020-01-18 06:36:35 -05:00
parent e2ace10dbc
commit 406bd7a2ea

View File

@@ -1115,23 +1115,25 @@ class ProcessPageSearchLive extends Wire {
$group = ''; $group = '';
$groups = array(); $groups = array();
$totals = array(); $totals = array();
$icon = wireIconMarkup('angle-right'); $counts = array();
$btn = $this->modules->get('InputfieldButton'); /** @var InputfieldButton $btn */
$btn->aclass = "$prefix-view-all";
foreach($items as $item) { foreach($items as $item) {
if($item['group'] != $group) { if($item['group'] != $group) {
$group = $item['group']; $group = $item['group'];
$groups[$group] = ''; $groups[$group] = '';
} }
$counts[$group] = isset($counts[$group]) ? $counts[$group] + 1 : 1;
if(empty($totals[$group]) && isset($item['n'])) { if(empty($totals[$group]) && isset($item['n'])) {
list(, $total) = explode('/', $item['n']); list(, $total) = explode('/', $item['n']);
$totals[$group] = (int) $total; $totals[$group] = (int) $total;
} }
if($item['name'] === 'view-all') { if($item['name'] === 'view-all') {
if($pagination) continue; if($pagination) continue;
$groupLabel = $this->wire('sanitizer')->entities($group); $btn->href = $item['url'];
$groups[$group] .= $btn->value = "$item[title] > $group (" . $totals[$group] . ")";
"<p><a class='$prefix-view-all' href='$item[url]'>" . $groups[$group] .= $btn->render();
"$item[title] $icon $groupLabel (" . $totals[$group] . ")</a></p>";
} else { } else {
$groups[$group] .= $this->renderItem($item, $prefix) . '<hr />'; $groups[$group] .= $this->renderItem($item, $prefix) . '<hr />';
} }
@@ -1139,7 +1141,7 @@ class ProcessPageSearchLive extends Wire {
$totalGroups = array(); $totalGroups = array();
foreach($groups as $group => $content) { foreach($groups as $group => $content) {
$total = $totals[$group]; $total = empty($totals[$group]) ? $counts[$group] : (int) $totals[$group];
$totalGroups["$group ($total)"] = $content; $totalGroups["$group ($total)"] = $content;
unset($groups[$group]); unset($groups[$group]);
} }