We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3785
    • 143 Posts
    Hello fellow MODx users and developers smiley

    I just ran into a problem with the AjaxSearch Snippet I could not solve by myself and also didn’t find any solution in the forums:

    I have a multilingual website and want to limit the search results to the currently selected language. Is there any possibility to tell the AjaxSearch snippet to search down only a specific document, like we have the &startId in Ditto and Wayfinder?

    Thanks for your help!

    Bogdan

      Medianotions – Studio für Webdesign
      http://www.medianotions.de
      • 10449
      • 956 Posts
      In assets/snippets/AjaxSearch/AjaxSearch.inc.php, there’s line 158 with:

      $sql .= $qry_sql . "sc.published = 1 AND sc.searchable=1 AND sc.deleted=0;";

      You could add another filter here at the end of the query. Of course, then you would have to duplicate the snippet for every language, because the setting would be hard-coded.
      e.g.
      $sql .= $qry_sql . "sc.published = 1 AND sc.searchable=1 AND sc.deleted=0 AND sc.parent=5;"; // only search docs within folder id 5
      $sql .= $qry_sql . "sc.published = 1 AND sc.searchable=1 AND sc.deleted=0 AND sc.parent=100;"; // only search docs within folder id 100

      Changing the code to accept one more paramenter (e.g. &restrictToParent=`100`) wouldn’t be that hard I guess...
        • 3785
        • 143 Posts
        Hello Ganesh,

        thanks for the hint I could indeed solve my problem and even managed to ad a $startId snippet parameter - hurray wink

        I think it would be nice and useful to have this additional parameter build in the next version of AjaxSearch. I’ll send the link of this post to Kyle Jaebker, maybe he will consider it.

        Thanks again

        Bogdan


          Medianotions – Studio für Webdesign
          http://www.medianotions.de
        • Quote from: ganeshXL at Jun 16, 2007, 10:43 PM

          In assets/snippets/AjaxSearch/AjaxSearch.inc.php, there’s line 158 with:

          $sql .= $qry_sql . "sc.published = 1 AND sc.searchable=1 AND sc.deleted=0;";


          You could add another filter here at the end of the query. Of course, then you would have to duplicate the snippet for every language, because the setting would be hard-coded.
          e.g.
          $sql .= $qry_sql . "sc.published = 1 AND sc.searchable=1 AND sc.deleted=0 AND sc.parent=5;"; // only search docs within folder id 5
          $sql .= $qry_sql . "sc.published = 1 AND sc.searchable=1 AND sc.deleted=0 AND sc.parent=100;"; // only search docs within folder id 100


          Changing the code to accept one more paramenter (e.g. &restrictToParent=`100`) wouldn’t be that hard I guess...
          That’d be a great, and straightforward addition indeed. Thanks for the suggestion.
            Ryan Thrash, MODX Co-Founder
            Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
            • 30223
            • 1,010 Posts
            Oops,... Thanks for alerting me. smiley build this great working multilingual site and never bothered to check the search embarrassed
              • 14471
              • 1 Posts
              I would actually like to be able to search a specific group of ID’s. That way I could limit the search to my faq’s section.

              -John Blair (KoX)
                • 10449
                • 956 Posts
                Well, if your FAQ docs are all in one folder, the above suggestion should work fine. Did you try it?
                  • 2954
                  • 40 Posts
                  The approach suggested limits to only documents with a shared parent. I use nested documents to categorize products, so it wasn’t finding any.

                  Then I got the idea to have it filter documents by template type. All my products have a template "Product Detail" with id 10, so by modifying this line in AjaxSearch.inc.php

                  $sql .= $qry_sql . "sc.published = 1 AND sc.searchable=1 AND sc.deleted=0;";

                  to

                  $sql .= $qry_sql . "sc.published = 1 AND sc.searchable=1 AND sc.deleted=0 AND sc.template=10;";

                  However I couldn’t get it to work. Any Suggestions?
                    • 7231
                    • 4,205 Posts
                    check out this ajaxSearch modification files that include all of these features. Note I have not used this yet myself but plan to on my next site (if they really work that is).

                    http://modxcms.com/forums/index.php/topic,5357.msg123851.html#msg123851
                      [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                      Something is happening here, but you don't know what it is.
                      Do you, Mr. Jones? - [bob dylan]