On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Hi,

    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.

    Thanks.

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

    • discuss.answer
      Solution:

      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.