SimpleSearch: Filter results by Template/TV?

With SimpleSearch you could use a custom driver.
This would be faster than running one query to get the IDs and then a second one to do the actual search.

I created this Github repository some while ago as an example:

Basically what you have to do is the following:

  • Create a custom folder in core/components with a “bootstrap.php” to load your custom class.
  • Add a namespace for this custom folder in the MODX manager (:gear: → “Namespaces”)
  • Use either the default driver class from SimpleSearch (core/components/simplesearch/src/Driver//SimpleSearchDriverBasic.php) or src/Driver/Custom.php from my Github repo as the starting point and hard-code the specific changes you need to filter the query.
  • Change the system setting simplesearch.driver_class to your custom driver class.