From 5fe181c315688c421fdf6fa1dce798839831dd47 Mon Sep 17 00:00:00 2001 From: Ryan Cramer Date: Fri, 1 Mar 2024 15:57:20 -0500 Subject: [PATCH] Update ProcessPageSearchLive to simplify id searches when using single equals sign --- .../Process/ProcessPageSearch/ProcessPageSearchLive.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wire/modules/Process/ProcessPageSearch/ProcessPageSearchLive.php b/wire/modules/Process/ProcessPageSearch/ProcessPageSearchLive.php index 7d3e1324..76d51b5c 100644 --- a/wire/modules/Process/ProcessPageSearch/ProcessPageSearchLive.php +++ b/wire/modules/Process/ProcessPageSearch/ProcessPageSearchLive.php @@ -303,7 +303,11 @@ class ProcessPageSearchLive extends Wire { } if(empty($operator) || !in_array($operator, $this->allowOperators)) { - $operator = strpos($q, ' ') ? $this->multiWordOperator : $this->singleWordOperator; + if(in_array($property, array('id', 'status', 'templates_id', 'parent_id'))) { + $operator = '='; + } else { + $operator = strpos($q, ' ') ? $this->multiWordOperator : $this->singleWordOperator; + } } // check if type and property may be part of query: $q @@ -363,6 +367,7 @@ class ProcessPageSearchLive extends Wire { if($property && ($fields->isNative($property) || $fields->get($property)) && !in_array($lp, $this->skipProperties)) { // we recognize this property as searchable, so add it to the selector if($lp == 'status' && !$user->isSuperuser() && $value > Page::statusHidden) $value = Page::statusHidden; + if($lp == 'id' && $operator === $this->liveSearchDefaults['operator']) $operator = '='; $selectors[] = $property . $operator . $value; } else { // we did not recognize the property, so use field(s) defined in module instead