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

    Just saw that the latest version of AjaxSearch is wrapping span tags around keywords.
    I have tried to set:

    &highlightResult=0

    But the spans are still being inserted into my code. The problem occurs as I have some js being generated dynamically by another snippet, and AjaxSearch is putting spans in my js, and breaking the functions im generating.

    Is there a way to prevent this without hacking the class files?

    Thanks

    J
      • 15083
      • 697 Posts
      I changed line 1410 of search.class.inc.php to:
      $resultLink = $modx->makeUrl($row[$id],’’,’searched=’.urlencode($this->searchString).’&advsearch=’.urlencode($this->advSearch));

      No more search highlighting my javascript please smiley
        • 18940
        • 152 Posts
        Thnx!!!
        I spend hours looking why my website kept having a ’>’ tag placed on my header.
        I almost recoded my template grin
          Quality doesn't need a big signature.
          • 5811
          • 1,717 Posts
          @jusmeig
          &highlightResult=0 .... But the spans are still being inserted into my code
          Not sure to understand. When &highlightResult=`0` the search terms are not highlighted because no spans are inserted around.

          classes/search.class.inc.php file:
          if ($this->cfg[’highlightResult’]){
          $rank = $extracts[$i][’rank’];
          $searchTerm = $searchList[$rank-1];
          $extract = preg_replace( ’/’ . preg_quote( $searchTerm, ’/’ ) . ’/’ .$this->pcreModifier, ’<span class="’.$highlightClass.’ ’.$highlightClass.$rank.’">\0</span>’, $extract);
          }
          So with $this->cfg[’highlightResult’] = 0 no span are added.


          Are you sure that your highlightResult parameter is correctly set to zero ?
          To control it, set &debug=`1` and check the value in the file ajaxSearch_log.txt in the ajaxSearch folder.
            • 18940
            • 152 Posts
            I had it set to 0 but it kept showing, with his quickfix <span class="ajaxSearch_highlight ajaxSearch_highlight1"> is still inserted and it’s working without breaking the page so I suppose this code line should be updated?

            EDIT: N.v.m. fixed: http://svn.modxcms.com/jira/browse/AJAXSEARCH-38

            Just my two cents.
              Quality doesn&#39;t need a big signature.
              • 2023
              • 7 Posts
              Thanks for that fix, I’ve really been scratching my head and seeing rogue `>` in my dreams!