We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31415
    • 11 Posts
    AjaxSearch results are reading the top of a page with an index of jump links. The text in the search result gets through to the middle of a link tag, splitting the
    <a href="#">Some text that is a live link....

    and then the live link carries over into the sidebar text, etc, until it hits another actual link closing tag and gets turned off. This makes the following text confusing and looking ugly besides.

    I’ve looked in this forum for some help but don’t even know how to name the problem. I checked over the AjaxSearch parameters. Would the
    &stripOutput function help here? huh tongue
      • 5811
      • 1,717 Posts
      Would the &stripOutput function help here?
      Yes. The default stripOutput fonction is defined as follow:
      /**
       * defaultStripOutput : default ouput strip function  
       */
        function defaultStripOutput($text){
      
         if ($text !== ''){
            // replace line breaking tags with whitespace
            $text = stripLineBreaking($text);
            // strip modx sensitive tags
            $text = stripTags($text);
            // strip Jscripts
            $text = stripJscripts($text);
            // strip html tags. Tags should be correctly ended
            $text = stripHTML($text);  
          }
          return $text;
        }
      So the stripHTML function cleans your links. To avoid that, in your config file, defined your own stripOutput function with something like that:
      /**
       *  stripHtmlExceptLink : Remove HTML sensitive tags except link tag <a></a>
       */
      function stripHtmlExceptLink($text){
        $text = strip_tags($text,'<a>');
        return $text;
      }
      
      function myStripOutput($text){
      
          if ($text !== ''){
            // replace line breaking tags with whitespace
            $text = stripLineBreaking($text);
            // strip modx sensitive tags
            $text = stripTags($text);
            // strip Jscripts
            $text = stripJscripts($text);
            // strip html tags. Tags should be correctly ended
            $text = stripHtmlExecptLink($text);  
          }
          return $text;
      }
      


      Here the function strip_tags($text,’<a>’); save your links. See Strip_tags
      Functions stripLineBreaking(), stripTags() and stripJscripts() are provided by AjaxSearch. So don’t redefined them.

      And finally adds &stripOutput=`myStripOutput` in your snippet call

      Try it and let me know the results.
        • 31415
        • 11 Posts
        Thank you for your reply.

        I am using modx 0.9.6.1p2; in the AjaxSearch directory, there are a limited number of files... there is no configs folder, so I can’t locate the config file which the wiki says is

        The default configuration file is configs/default.config.php

        I downloaded the AjaxSearch snippet from http://modxcms.com/AjaxSearch-490.html and the contents look very different from the AjaxSearch snippet folder that is incorporated with modx. Is the AS config function made part of some other file? the general modx config or...?



          • 31415
          • 11 Posts
          I just checked in the admin panel, Manage Resources/snippets/AjaxSearch, and in that file there is a section...

          // CONFIGURE

          // MAIN SNIPPET SETUP OPTIONS
          // --------------------------


          Is this now where the config stripOutput function should be added?
            • 5811
            • 1,717 Posts
            Version 0.9.6.1p2 is delivered with the version 1.7.1 of AjaxSearch. The &stripOutput parameter is provided with the version 1.8.1 of AjaxSearch.
            So, yes, go to http://modxcms.com/AjaxSearch-490.html, download the version 1.8.1 and try it.
            This last version is compatible with 0.9.6.1

            Is the AS config function made part of some other file? the general modx config or...?
            Regarding config file you have 2 options.
            1/ you use the default file (configs/default.config.php)
            2/ you create a new config file and you use the &config parameter e.g: &config=`myOwnConfig`

            Put the 2 functions stripHtmlExecptLinks and myStripOutput inside it and run it. Don’t forget to add &stripOutput=`myStripOutput` in your snippet call
              • 31415
              • 11 Posts
              Okay... it’s working. I did a parallel installation which I called ajaxSearch2, just in case I wanted to go back to the former AjaxSearch.

              in case someone else uses this thread for help, I also had set it up so that the results would up on a second page and THAT call to AjaxSearch2 on the results page also needed to reference the new snippet ajaxSearch2. Duh. But it took me a while to figure it out.

              Thanks, Coroico, for your help.