SimpleSearch is not limiting to either the set context or the IDs
[!SimpleSearch?
&tpl=`archives-simple-search-result-tpl`
&containerTpl=`archives-simple-container-tpl`
&perPage=`0`
&contexts=`archives`
&andTerms=`0`
&ids=`213`
]]
It shows results from all contexts and resources that are not children of resource 213.
Site running on MODXCloud version 2.8.4. All extras are up to date.
thanks
Roy
The problem is the the property &andTerms=`0`
.
When set to 0
, brackets in the WHERE clause of the SQL query are missing and this results in a faulty query.
If you really need &andTerms
to be 0
, you could try adding the lines
if (!$andTerms) {
$whereGroup++;
}
at this position in the code:
if ($clause[3] > $prevWhereGrp) {
$c->andCondition(array('AND:id:!=' => ''), null, $prevWhereGrp);
} // hack xpdo to prefix the whole thing with AND
$prevWhereGrp = $clause[3];
if ($andTerms) {
$whereGroup++;
}
}
$c->andCondition(array('AND:id:!=' => ''), null, $whereGroup - 1); // xpdo hack: pad last condition...
} else {
$fields = $this->modx->getSelectColumns('modResource', '', '', $docFields);
if (is_array($customPackages) && !empty($customPackages)) {
foreach ($customPackages as $package) {
$fields .= (!empty($fields) ? ',' : '') . $this->modx->getSelectColumns($package[0], $package[0], '', explode(',', $package[1]));
if (!empty($package[4])) {
$c->where($package[4]);
}
}
This seems to work, but the code is pretty ugly and someone should probably take a proper look at it.
@halftrainedharry That worked just fine. I will just have to remember if we update SimpleSearch to modify the coded again.
Yes, I prefer using OR for this search between the terms.
Thanks
Roy
Maybe you can create an issue on github and hope that the bug gets fixed when the next version is released.
Although currently there are two different versions of SimpleSearch (for MODX 2.x and 3.x respectively) and they are seemingly in different repositories maintained by different people.
I think these are the correct repositories (but I could be mistaken as the situation is quite unclear):
For MODX 2.x: GitHub - Sterc/SimpleSearch: A simple search component for MODx Revolution
For MODX 3.x: GitHub - modxcms/SimpleSearch: A simple search component for MODx Revolution
system
Closed
October 14, 2022, 8:18am
6
This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.