We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15001
    • 697 Posts

    Is there a way to make the "Highlight Search" plugin highlighting words only in the search results but not in the linked pages?

    When having &highlightResult=`1`, the matching words in both AjaxSearch results and linked pages are highlighted.


    This question has been answered by Jul. See the first response.

    • discuss.answer
      • 15001
      • 697 Posts

      In the file assets/snippets/ajaxSearch/classes/ajaxSearchOutput.class.inc.php :

      1. Comment out the if {} else {} sandwich starting at line 741.
      2. Add the line 748, just below the code you commented out.

             /* Disabled : highlighting in linked ressources
              if ($this->asCfg->cfg['highlightResult'] && $hClass) {
                  $resultLink = $modx->makeUrl($row[$id], '', 'searched=' . urlencode($this->asCtrl->searchString) . '&advsearch=' . urlencode($this->asCtrl->advSearch) . '&highlight=' . urlencode($hClass));
              } else {
                  $resultLink = $modx->makeUrl($row[$id]);
              $resultLink = $modx->makeUrl($row[$id]);

      AjaxSearch will link the matching pages, but without the parameters in URLs that were doing the highlighting in linked pages.