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

    Ik wil graag ervoor zorgen dat AjaxSearch zoek binnen een bepaalde parent. Ik ben namelijk bezig met een drietalige website en wil dat AjaxSearch binnen 1 taal zoekt. Daarbij heb ik bijvoorbeeld dat de nederlandstalige site id 2 heeft. Maar als ik dan &parents=`2` meegeef als parameter, dan krijg ik nog steeds resultaten van de andere talen.

    Kan iemand mij uithelpen? Heb ik iets over het hoofd gezien?

    Alvast bedankt.

    Oja, ik maak ook gebruik van &depth om aan te geven hoe diep hij moet zoeken
      • 32646
      • 87 Posts
      Ik kan en klein beetje Nederlands spreken. Heb je UltimateParent probeerd?

      [!AjaxSearch? &parents=`[[UltimateParent]]` &language=`[*Lang*]` &ajaxSearchType=`1` &addJscript=`0` !]
        Just learning the ropes.
        • 18985
        • 29 Posts
        Thank you for your advice. Unfortunatly, it does not seem to work. I want to search the documents below id 72, the document id of the search page is 128, wich is, let’s say a grand-child of id 72.

        Currently I have this:
        [!AjaxSearch? &ajaxSearch=`1` &highlightResult=`1` &parents=`[[UltimateParent? &id=`128` &top=`1`]]` &depth=`2` &language=`english`!]

        I’ve also tried:
        &parents=`[[UltimateParent? &id=`72` &top=`128`]]` (and reverse)
        &parents=`[[UltimateParent? &id=`72` &top=`1`]]` (and reverse)

        Id 1 is my indexpage for those who are interested.

        Document tree is as follows:
        + (english website) 72 <--- Search in this parent and childs
        - (page)
        + (id) 128
        - pages....
        - (searchpage) 128
        + (some other page I also want to search in)
        + (dutch site)
        + (german site)

        So, does anyone got a clue? What am I doing wrong?
          • 32646
          • 87 Posts
          Yes, your English is much better than my Dutch.

          Check your source code on the generated page. It should list the pages it is searching:

          listIDs = '72,128, etc';


          If the list isn’t right, then something is happening when it is creating that list.
            Just learning the ropes.
            • 18985
            • 29 Posts
            I would like to know where I can find that piece of code. (listIDs = ’72,128, etc’;) I also do not generate a new page, it all happens on the same page.

            I still cannot get it to work.

            Hierarchy:
            Index (1) <-- redirects to id=5
            +en (72)
            +de (39)
            +nl (2) <-- AjaxSearch called on id=124 need to search in id=2 and below.
            indexpage (5)
            +info
            +news
            searchpage (124) <-- AjaxSearch call
            otherpages

            Am i correct to think as follows:
            [[UltimateParent? &topLevel=`1`]] searches in pages below level 1, so below id=1 in my example
            [[UltimateParent? &id=`124` &top=`2`]] searches in pages below id=2 in my example

            Can someone maybe give an example, according to the example-hierarchy mentioned above? It would also be exellent to mention on wiki.
            Somehow my search results keep comming from the entire website.

            @ wordcooper: Thank you for your help sofar.
              • 5811
              • 1,717 Posts
              @Hi Meddiecap

              Please find an example here : http://www.modx.wangba.fr/index.php?id=154

              In this example, AjaxSearch snippet call is on the page #154. And [[UltimateParent? &id=`154` &top=`50`]] allows a search in the children documents of #106 (AjaxSearch 1.7.1). So if you search "MySQL" you get the document #101 (Behind the scene -SQL) which is the "uncle" of document #154. Look at the enclosed image of hierarchy to understand.

              I would like to know where I can find that piece of code. (listIDs = ’72,128, etc’)
              Since the 1.7.1 the total list of ids don’t appear in the javascript code. Only the parents or documents ids.
              So, if you look at the code of this example, you find : idgrp = ’106’; Which means that the search will occurs among the children documents of documents #106. And Not #50.
              From #154 you Get #106 as ultimate parent. And then AjaxSearch search among the children of #106 = #107, #113, #117, #101

              With a local copy of your site, to get a log of the exact list of ids where the search will occur, adds line 259, just before the return statement, in the file includes/ajaxSearch.inc.php , this code line:
              $f=fopen('AjaxSearch_log.txt','w+');fwrite($f,"AjaxSearch listIDs = ".$listIDs." \n\r");
              and then look at the file AjaxSearch_log.txt inside the root folder of your site.
              Don’t forget to remove this line before uploading on your production server.

              In your case, I think that [[UltimateParent? &id=`124` &top=`2`]] give info as ultimate parent and &Parents([[UltimateParent? &id=`124` &top=`2`]]) do a search in children of Info = news, otherpages ...
                • 32646
                • 87 Posts
                I would like to know where I can find that piece of code. (listIDs = ’72,128, etc’Wink I also do not generate a new page, it all happens on the same page.

                Right-click on your webpage and click View Page Source. That is the source code I am talking about. You will see Javascript code setting the variables:

                <!-- start AjaxSearch header -->
                <script type="text/javascript">
                as_version = '1.7';
                debug = 0;
                as_language = 'en';
                opacity = 1;
                stripHtml = 1;
                stripSnip = 1;
                stripSnippets = 1;
                useAllWords = 1;
                searchStyle = 'partial';
                minChars = 3;
                ajaxMax = 4;
                showMoreResults = 0;
                moreResultsPage = 240;
                extract = 1;
                extractLength = 200;
                liveSearch = 1;
                docgrp = '';
                highlightResult = 1;
                listIDs = '607,604,47,605,606,589,593,590,681,716,717,594,203,229,180,608,609,214,610,223,611,613,612,614,615,650,651,652,653,654,655,656,657,658,659,721,648,649,647,6,623,601,718,646,719,724,595,722,205,207,641,642,643,234,673,644,645,638,639,660,674,197,185,193,220,675,676,678,677,679,218,680,662,661,664,663,665,667,666,668,669,670,671,682,683,684,685,686,687,688,689,690,691,692,693,694,695,696,699,697,698,700,701,702,703,704,705,710,711,712,713,714,715,706,707,709,708,628,622,619,624,632,640,599,625,617,618,626,627,620,616,600';
                
                </script>
                <!-- end AjaxSearch header -->
                  Just learning the ropes.
                  • 5811
                  • 1,717 Posts
                  Hi Wordcooper

                  With the 1.7.0 you had the full list of ids in the javascript code, but with the last version 1.7.1 you have only a docid parameter (parent id or listid of the documents parameter).
                  Go on the demo site and runs the two version of AS. You will see the differences in the javascript code.


                  Extract of the AjaxSearch 1.7.1 presentation:

                  -- CHANGE REQUESTS IMPLEMENTED --

                  - Search in hidden documents from menu
                  http://modxcms.com/forums/index.php/topic,5357.msg144232.html#msg144232]

                  Documents flaged with hidden should only be shown in the result list, if the user wants to.

                  - Advanced search
                  The following search are now allowed:
                  * exactphrase : the exact phrase is used as searchstring
                  * allwords : search the documents which contains all the search terms
                  * oneword : search the documents which contains at least one word
                  * nowords : search the documents which do not contain the words

                  - Use the same code between ajax and no ajax mode for the search function.
                  Instanciate a modx object rather than doing direct mysql calls

                  - With the ajax mode, the complete list of IDs is now hidden in the code source of the page.
                  Only the parents or the documents Ids are visible

                    • 32646
                    • 87 Posts
                    Thanks, I must have missed that update.
                      Just learning the ropes.