We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30562
    • 99 Posts
    Thanks.
      • 5628
      • 44 Posts
      Hi
      Anyone know how to exclude snippets from AjaxSearch results?
      My google-fu is weak today and can’t seem to find anything in the forums!
      For example, when searching for a term that is used as a snippet parameter on a page, AjaxSearch will return that in the results.
      However, searching for a snippet name itself - eg. Ditto - will return no results so obviously there is some filtering taking place.

      Cole
        • 5811
        • 1,717 Posts
        With ajaxSearch 1.7, the filtering is taking place in the stripSnip function from the includes/ajaxSearch.inc.php file.
        I am interested by an extract of your document in order to understand why the filtering doesn’t fit as awaited. In advance thanks for this feedback.
          • 30562
          • 99 Posts
          Quote from: sottwell at Feb 13, 2008, 01:25 AM

          An "onBeforeSearch" event then, passing the search term, that allows the user to create a custom pre-processor for the search term.
          What version of MODx is available in view of ? 0.9.6.1 or 0.9.7 ?
          There are different events in tab of plugins, but named as "onBeforeSearch" is absent.
          Me interests how practically to organise preprocessing and postprocessing of search terms in ajaxSearch 1.7 and MODx 0.9.6.1. I will be glad to any hint.

          Show a place in the documentation where it is possible to read what about you speak.
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            My comment was just the clarification of an idea put forward in an earlier post. It does not exist.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 5628
              • 44 Posts
              Quote from: coroico at Feb 13, 2008, 12:06 PM

              With ajaxSearch 1.7, the filtering is taking place in the stripSnip function from the includes/ajaxSearch.inc.php file.
              I am interested by an extract of your document in order to understand why the filtering doesn’t fit as awaited. In advance thanks for this feedback.

              Hi
              As an example, am specifying a Ditto snippet which is filtered using a TV associated with the content being requested (as follows).
              This is being called in the document content rather than within a template.

              [!Ditto? &parents=`115` &depth=`1` &hideFolders=`1` &sortBy=`pub_date` &display=`4` &paginate=`1` &paginateAlwaysShowLinks=`1`  &filter=`archiveDate,@EVAL return date('d-m-Y');,4`!]


              With this example, if I search the site for `arch` then the above page is being returned in the search results.
              Can probably filter it out with an exclusion filter on that page ID but would have thought there would be some means to filter anything enclosed in a snippet call.

              Thoughts?
                • 30562
                • 99 Posts
                Quote from: sottwell at Feb 14, 2008, 07:39 AM

                My comment was just the clarification of an idea put forward in an earlier post. It does not exist.
                At the same time.

                Is it possible to add possibility of search in comments from miniblog? I wrote about it earlier.
                  • 5811
                  • 1,717 Posts
                  @Coleh

                  I am just doing this simple test:
                  <?php
                  
                  $text = "[!Ditto? &parents=`115` &depth=`1` &hideFolders=`1` &sortBy=`pub_date` &display=`4` &paginate=`1` &paginateAlwaysShowLinks=`1`  &filter=`archiveDate,@EVAL return date('d-m-Y');,4`!]";
                  
                  $text = stripSnip($text);
                  echo "text->".$text."<-";
                  
                    function stripSnip($text){
                      // Regular expressions of things to remove from search string
                      $modRegExArray[] = '~\[\[(.*?)\]\]~';   // [[snippets]]
                      $modRegExArray[] = '~\[!(.*?)!\]~';     // [!noCacheSnippets!]
                      $modRegExArray[] = '!\[\~(.*?)\~\]!is'; // [~links~]
                      $modRegExArray[] = '~\[\((.*?)\)\]~';   // [(settings)]
                      $modRegExArray[] = '~{{(.*?)}}~';       // {{chunks}}
                      $modRegExArray[] = '~\[\*(.*?)\*\]~';   // [*attributes*]
                    
                      // Remove modx sensitive tags
                      foreach ($modRegExArray as $mReg)$text = preg_replace($mReg,'',$text);
                      return $text;
                    }
                  ?>
                  I get the following output
                  text-><-
                  So, I get as awaited an empty value for $text. The content inside the brackets is cleared as needed.

                  As the stripSnip is always called in the prepareSearchContent function in the output, I don’t know how I could investigate on this issue. I will try to set up a document with your snippet call and try to understand why the stripSnip don’t occur in your case. Could you give me your AjaxSearch snippet call. Thanks.
                    • 5628
                    • 44 Posts
                    Hi coroico
                    Quote from: coroico at Feb 14, 2008, 11:28 AM

                    So I don’t know How I could investigate on your issue. Are you sure that the stripSnip function is called ? Have you set the parameter &stripSnip to 0 in your AjaxSearch Snippet Call ? Could you check the value of this parameter by looking to the code of your page. And could you give me the AjaxSearch snippet call. Thanks.

                    The AjaxSearch call is
                    [!ajaxSearch? &AS_showForm=`1` &ajaxSearch=`0` &highlightResult=`0` &parents=`48,62,63,64` &AS_landing=`8`!]
                    


                    Mmm, wasn’t aware of stripSnip parameter, then realised had AjaxSearch 1.5 installed.
                    Installed 1.7 and still returning page including Ditto calls, even with stripSnip parameter. FYI ModX 0.9.6

                    Cole
                      • 30562
                      • 99 Posts
                      Here is an example of search. To show result in picture is easier than to formulate by words.

                      The underlined phrase (at the left side) is sent to search. The search inquiry is resulted on the right (terms through a comma). The "found" terms are allocated by red colour at the left side.

                      In an example some problems connected with highlighting.
                      Shortly. The superfluous is highlighted. The necessary is not highlighted.


                      I see the partial decision of a problem in searchHighlight plugin.

                      At first to highlight the terms having the big length. At the subsequent highlightings of shorter terms it is necessary to check, whether they enter in longer already highlighted. If yes, highlighting of short words to cancel.

                      It is absolutely not clear how to be with senseless highlighting has begun words or the word middle. The formalism is to think up not simply. sad

                      This discussion is closed to further replies. Keep calm and carry on.