We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10449
    • 956 Posts
    Is it possible to exclude certain strings from AS search results?

    Case in point: I use certain special strings inside the content to create a JS-powered "read more" feature (not a separate page, but loading more content in via jQuery, if you click on "read more").

    How can I hide these strings? i.e. I don’t want to see ".... extracted text from AS .... @@@SPLIT@@@ blah lorem ipsum regular text..."

    Do I need to write a plugin for AS? Can I use a filter? I read the docs, but only found instructions to exclude certain documents or TVs, but not parts of the content.
      • 5811
      • 1,717 Posts

      stripOutput parameter should do the trick ...

      from ajaxSearch_readme.txt:


      ---- &stripOutput user function (optional)
      to transform on fly the result output
      by default: defaultStripOutput

      StripOutput user function should be define in the config file as follow :

      // string functionName(string $text)
      // functionName : name of stripOutput function passed as &stripOutput parameter
      // $text : string php variable name as results
      // return the filtered results
      /*
      function myStripOutput($text){

      Any Php code which filter the results
      The following internal functions could be called:
      $text = stripTags($text); // strip all the MODx tags
      $text = stripJscript($text); // strip jscript
      $text = stripLineBreaking($text); // replace line breaking tags with whitespace
      $text = stripHtml($text); // strip all the html tags

      You could also developp you own filter based on regular expressions.
      See http://fr.php.net/manual/en/intro.pcre.php

      return $text;
      }
      */

      By default : defaultStripOutput function will be used if &stripOutput parameter
      is not set or if the function is not defined :

      function defaultStripOutput($text){

      // replace line breaking tags with whitespace
      $text = stripLineBreaking($text);
      // strip modx sensitive tags
      $text = stripTags($text);
      // strip Jscript
      $text = stripJscripts($text);
      // strip html tags. Tags should be correctly ended
      $text = stripHTML($text);

      return $text;
      }
        • 5811
        • 1,717 Posts

        @GaneshXL: do you solve your problem ?
          • 10449
          • 956 Posts
          Yes. However, I didn’t really know how to use that stripOutput parameter. I tried, but I was probably doing it wrong. Since the site launch date was already due last Friday, I resorted to a core hack (I know... bad form... but it works): I inserted a new line at line 130 of assets/snippets/ajaxSearch/classes/ajaxSearch.class.inc.php

          $modRegExArray[] = '~\@@@SPLIT@@@~s';


          Thanks for your help + suggestion. Gonna play around with it on a local MODX install when I have more time.