From 0f3728ae003833ad8d4639b48a27257158c22c8d Mon Sep 17 00:00:00 2001 From: sl1rt Date: Sun, 5 Dec 2021 00:47:46 +0300 Subject: [PATCH] Update simplesearchdriverbasic.class.php Add support for filtering search by template. Use &template=`id` or &tempalte=`id,id,id` this solution is helpfull when u need to search by products or etc --- .../simplesearch/driver/simplesearchdriverbasic.class.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/components/simplesearch/model/simplesearch/driver/simplesearchdriverbasic.class.php b/core/components/simplesearch/model/simplesearch/driver/simplesearchdriverbasic.class.php index 969e3c0..7d12f7f 100644 --- a/core/components/simplesearch/model/simplesearch/driver/simplesearchdriverbasic.class.php +++ b/core/components/simplesearch/model/simplesearch/driver/simplesearchdriverbasic.class.php @@ -232,6 +232,11 @@ public function search($str, array $scriptProperties = array()) { $c->where(array('published:=' => 1), xPDOQuery::SQL_AND, null, $whereGroup); $c->where(array('searchable:=' => 1), xPDOQuery::SQL_AND, null, $whereGroup); $c->where(array('deleted:=' => 0), xPDOQuery::SQL_AND, null, $whereGroup); + + if($scriptProperties['template']!='') + { + $c->where(array('template:IN' => [$scriptProperties['template']]), xPDOQuery::SQL_AND, null, $whereGroup); + } /* Restrict to either this context or specified contexts */ $ctx = !empty($this->config['contexts']) ? $this->config['contexts'] : $this->modx->context->get('key');