SimpleSearch not limiting to either context or parent IDs

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:

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
For MODX 3.x: GitHub - modxcms/SimpleSearch: A simple search component for MODx Revolution

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”.