mirror of
https://github.com/processwire/processwire.git
synced 2025-08-09 16:26:59 +02:00
Fix issue processwire/processwire-issues#1066
This commit is contained in:
@@ -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]);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user