mirror of
https://github.com/processwire/processwire.git
synced 2025-08-18 20:41:16 +02:00
Upgrade ProcessPageSearchLive "view all" search results to use tabs rather than headings for improved usability
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
* in order to save resources. As a result, anything iterating through these Modules should check to make sure it's not a ModulePlaceholder
|
||||
* before using it. If it's a ModulePlaceholder, then the real Module can be instantiated/retrieved by $modules->get($className).
|
||||
*
|
||||
* ProcessWire 3.x, Copyright 2016 by Ryan Cramer
|
||||
* ProcessWire 3.x, Copyright 2019 by Ryan Cramer
|
||||
* https://processwire.com
|
||||
*
|
||||
* #pw-summary Loads and manages all modules in ProcessWire.
|
||||
@@ -3034,7 +3034,7 @@ class Modules extends WireArray {
|
||||
*
|
||||
*/
|
||||
public function getModuleInfoProperty($class, $property, array $options = array()) {
|
||||
if(isset($this->moduleInfoVerboseKeys[$property])) {
|
||||
if(in_array($property, $this->moduleInfoVerboseKeys)) {
|
||||
$info = $this->getModuleInfoVerbose($class, $options);
|
||||
$info['verbose'] = true;
|
||||
} else {
|
||||
@@ -3251,6 +3251,9 @@ class Modules extends WireArray {
|
||||
* $data = $modules->getConfig('HelloWorld');
|
||||
* $data['greeting'] = 'Hello World! How are you today?';
|
||||
* $modules->saveConfig('HelloWorld', $data);
|
||||
*
|
||||
* // Getting just one property 'apiKey' from module config data
|
||||
* @apiKey = $modules->getConfig('HelloWorld', 'apiKey');
|
||||
* ~~~~~~
|
||||
*
|
||||
* #pw-group-configuration
|
||||
@@ -3258,7 +3261,7 @@ class Modules extends WireArray {
|
||||
*
|
||||
* @param string|Module $class
|
||||
* @param string $property Optionally just get value for a specific property (omit to get all config)
|
||||
* @return array Module configuration data
|
||||
* @return array|string|int|float Module configuration data, returns array unless a specific $property was requested
|
||||
* @see Modules::saveConfig()
|
||||
* @since 3.0.16 Use method getModuleConfigData() with same arguments for prior versions (can also be used on any version).
|
||||
*
|
||||
@@ -3293,14 +3296,6 @@ class Modules extends WireArray {
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alias of getConfig() for backwards compatibility
|
||||
*
|
||||
* @param string|Module $className
|
||||
* @return array
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Get the path + filename (or optionally URL) for this module
|
||||
*
|
||||
|
@@ -1448,6 +1448,7 @@ class Pages extends Wire {
|
||||
$manager = $page->getPagesManager();
|
||||
if($manager instanceof PagesType) $manager->added($page);
|
||||
}
|
||||
$page->setQuietly('_added', true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -398,7 +398,7 @@ class WireDatabasePDO extends Wire implements WireDatabase {
|
||||
static public function getQueryLog() {
|
||||
/** @var WireDatabasePDO $database */
|
||||
$database = wire('database');
|
||||
$database->queryLog();
|
||||
return $database->queryLog();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -1 +1 @@
|
||||
ProcessPageSearch={t:0,defaultLabel:"Search",lastQuery:"",search:function(){var a=$("#ProcessPageSearchQuery").val();if(a==this.lastQuery){return false}$("#ProcessPageSearchStatus").text("Searching");$("#ProcessPageSearchLiveResults").load(ProcessWire.config.urls.admin+"page/search/",{q:a},function(c){var b=parseInt($("#search_num_results").hide().text());if(b){$("#search_results").fadeIn("fast").find("a").click(function(){$("#search_results").css("overflow","hidden")});$("#search_status").text(b+" matches")}else{$("#search_status").text("No matches")}});this.lastQuery=a;return false},hide:function(){$("#search_results").fadeOut("fast",function(){$(this).remove()});$("#search_status").text("");$("#search_query").val(this.defaultLabel)},init:function(){this.lastQuery=this.defaultLabel;$("#container").append('<div id="search_container"></div><div id="search_status"></div>');$("#search_form").unbind().submit(function(){return this.search()});$("#search_query").attr("autocomplete","off").focus(function(){$(this).keyup(function(){if($(this).val().length<4){return}if(this.t){clearTimeout(this.t)}this.t=setTimeout("liveSearch.search()",500)})}).blur(function(){setTimeout("liveSearch.hide()",250)})}};$(document).ready(function(){});
|
||||
ProcessPageSearch={t:0,defaultLabel:"Search",lastQuery:"",search:function(){var query=$("#ProcessPageSearchQuery").val();if(query==this.lastQuery)return false;$("#ProcessPageSearchStatus").text("Searching");$("#ProcessPageSearchLiveResults").load(ProcessWire.config.urls.admin+"page/search/",{q:query},function(data){var numResults=parseInt($("#search_num_results").hide().text());if(numResults){$("#search_results").fadeIn("fast").find("a").click(function(){$("#search_results").css("overflow","hidden")});$("#search_status").text(numResults+" matches")}else{$("#search_status").text("No matches")}});this.lastQuery=query;return false},hide:function(){$("#search_results").fadeOut("fast",function(){$(this).remove()});$("#search_status").text("");$("#search_query").val(this.defaultLabel)},init:function(){this.lastQuery=this.defaultLabel;$("#container").append('<div id="search_container"></div><div id="search_status"></div>');$("#search_form").unbind().submit(function(){return this.search()});$("#search_query").attr("autocomplete","off").focus(function(){$(this).keyup(function(){if($(this).val().length<4)return;if(this.t)clearTimeout(this.t);this.t=setTimeout("liveSearch.search()",500)})}).blur(function(){setTimeout("liveSearch.hide()",250)})}};$(document).ready(function(){});
|
@@ -597,7 +597,8 @@ class ProcessPageSearchLive extends Wire {
|
||||
$order++;
|
||||
}
|
||||
|
||||
if($n && $n < $result['total'] && !$this->isViewAll && !$help) {
|
||||
//if($n && $n < $result['total'] && !$this->isViewAll && !$help) {
|
||||
if($n && $n < $result['total'] && !$help) {
|
||||
$url = isset($result['url']) ? $result['url'] : '';
|
||||
$items[$order] = $this->makeViewAllItem($liveSearch, $thisType, $item['group'], $result['total'], $url);
|
||||
}
|
||||
@@ -1110,25 +1111,45 @@ class ProcessPageSearchLive extends Wire {
|
||||
protected function ___renderList(array $items, $prefix = 'pw-search', $class = 'list') {
|
||||
|
||||
$pagination = $this->pagination->renderPager();
|
||||
$a = array();
|
||||
$group = '';
|
||||
|
||||
$out = "\n<div class='$class'>" . $pagination;
|
||||
$groups = array();
|
||||
$totals = array();
|
||||
$icon = wireIconMarkup('angle-right');
|
||||
|
||||
foreach($items as $item) {
|
||||
$headline = '';
|
||||
if($item['group'] != $group) {
|
||||
$group = $item['group'];
|
||||
$headline = "<h2>" . $this->wire('sanitizer')->entities($group) . "</h2>";
|
||||
list(,$total) = explode('/', $item['n']);
|
||||
$totals[$group] = (int) $total;
|
||||
$groups[$group] = '';
|
||||
}
|
||||
if($item['name'] === 'view-all') {
|
||||
if($pagination) continue;
|
||||
$groupLabel = $this->wire('sanitizer')->entities($group);
|
||||
$groups[$group] .=
|
||||
"<p><a class='$prefix-view-all' href='$item[url]'>" .
|
||||
"$item[title] $icon $groupLabel (" . $totals[$group] . ")</a></p>";
|
||||
} else {
|
||||
$groups[$group] .= $this->renderItem($item, $prefix) . '<hr />';
|
||||
}
|
||||
$a[] = $headline . $this->renderItem($item, $prefix);
|
||||
}
|
||||
|
||||
$out .= implode('<hr />', $a) . $pagination . "\n</div>";
|
||||
|
||||
return $out;
|
||||
$totalGroups = array();
|
||||
foreach($groups as $group => $content) {
|
||||
$total = $totals[$group];
|
||||
$totalGroups["$group ($total)"] = $content;
|
||||
unset($groups[$group]);
|
||||
}
|
||||
|
||||
$wireTabs = $this->wire('modules')->get('JqueryWireTabs');
|
||||
|
||||
return
|
||||
"<div class='pw-search-$class'>" .
|
||||
$pagination .
|
||||
$wireTabs->render($totalGroups) .
|
||||
$pagination .
|
||||
"</div>";
|
||||
}
|
||||
/**
|
||||
* Render an item for the “view all” list
|
||||
*
|
||||
|
Reference in New Issue
Block a user