We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9670
    • 48 Posts
    Multilingual search with AjaxSearch:

    1. Create chunk AS_Result, where we need to change page title
    from AjaxSearch type ( [+as.pagetitle+] )
    to YAMS type ( [[YAMS? &get=`content` &from=`longtitle` &docid=`[+as.id+]`]] )

    <div class="[+as.resultClass+]">
    <a class="[+as.resultLinkClass+]" href="[+as.resultLink+]" title="[+as.longtitle+]">[[YAMS? &get=`content` &from=`longtitle` &docid=`[+as.id+]`]]</a>
    [+as.descriptionShow:is=`1`:then=`
      <span class="[+as.descriptionClass+]">[+as.description+]</span>
    `+]
    [+as.extractShow:is=`1`:then=`
      <div class="[+as.extractClass+]"><p>[+as.extract+]</p></div>
    `+]
    [+as.breadcrumbsShow:is=`1`:then=`
      <span class="[+as.breadcrumbsClass+]">[+as.breadcrumbs+]</span>
    `+]
    </div>


    2. Create search form with search in specified TV’s according to chosen language. The landing page in this example is 50.

    [!AjaxSearch? &ajaxSearch=`0` &AS_landing=`50` &AS_showResults=`0` &withTvs=`+:content_(yams_id),description_(yams_id),introtext_en,longtitle_(yams_id),menutitle_(yams_id),pagetitle_(yams_id)` &language=`(yams_mname)`!]
    


    Nota bene! We have to use &ajaxSearch=`0` because there is incorrect page title displaying in ajax mode takes place. This is due to ajaxResult.tpl template in ajax mode is rendered bypassing YAMS.

    3. Create landing page (in our example 50) within another AjaxSearch call:

    [!AjaxSearch? &ajaxSearch=`0` &AS_showForm=`0` &AS_showResults=`1` &tplResult=`AS_Result` &language=`(yams_mname)`!]


    4. Change redirection type in Modules → YAMS → Other Params → URL Redirection Settings → Redirection Mode to “Current else Browser” for correct redirection to pages searched.

    So it works now. This solution has limitations in ajax mode, and can produce some mistakes in search results, but enough correct for use.

    With tanks to PMS for help.
      • 22851
      • 805 Posts
      Yes. People have had success with using YAMS and AjaxSearch. Unfortunately, both Google and the MODx forums search seem to fail pretty miserably when you search for information. I tried a search for ’ajaxsearch’ using the MODx search within the YAMS forums only, but the only thread it found was this one!

      Here are the key points.
      - You need to tell AjaxSearch snippet call for each language to search in the appropriate multilingual template variables using the &withTvs AjaxSearch parameter. See the following post:
      http://modxcms.com/forums/index.php/topic,41682.msg238483.html#msg238483

      - The AjaxSearch standard results templates will produce standard MODx monolingual URLs and output the content from the standard document fields rather than multilingual content. To overcome this you can

      1. modify your templates as described in the following post:
      http://modxcms.com/forums/index.php/topic,41682.msg239095.html#msg239095

      2. instruct YAMS to stay in the current language by setting the
      Modules>YAMS>Other Params>URL redirection settings>Redirection Mode
      parameter to ’Current else Browser’ or ’Current’.

      3. With more recent alpha versions of YAMS you may also need to specify the id of the search results page in the
      Modules>YAMS>Other Params>URL redirection settings>MODx URLs
      parameter.

      Let us know how you get on.
        YAMS: Yet Another Multilingual Solution for MODx
        YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
        Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.
        • 16545
        • 358 Posts
        I’m confused ...

        Landing page has The page isn’t redirecting properly (FF),
        because of URL index.php?id=54&searched=test&advsearch=oneword&highlight=ajaxSearch_highlight+ajaxSearch_highlight1yams_lang=enyams_lang=enyams_lang=enyams_lang=enyams_lang=enyams_lang=enyams_lang=enyams_lang=enyams_lang=enyams_lang=enyams_lang=enyams_lang=enyams_lang=enyams_lang=enyams_lang=enyams_lang=enyams_lang=enyams_lang=enyams_lang=enyams_lang=en
          • 22851
          • 805 Posts
          Have you tried adding the language page document id to this list:

          Modules>YAMS>Other Params>URL redirection settings>MODx URLs

          ? (See point 3 above.)

          EDIT: Oh... labasus. Are you using YAMS 1.0.5 beta? If you are, then 1) the setting I mentioned above wont exist and 2) that redirection problem is probably a bug that has been solved in the latest alpha version.
            YAMS: Yet Another Multilingual Solution for MODx
            YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
            Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.
            • 9670
            • 48 Posts
            Thank you, PMS. I was confused when has found nothing too.

            Well.
            [!AjaxSearch? &ajaxSearch=`1` &moreResultsPage=`50` &showMoreResults=`1` &withTvs=`+:content_(yams_id),description_(yams_id),introtext_(yams_id),longtitle_(yams_id),menutitle_(yams_id),pagetitle_(yams_id)`!] 


            This returns right search result at the necessary language. But I stopped on templates.

            When I changed 2nd string in ajaxSearch.tpl from
              <a class="[+as.resultLinkClass+]" href="[+as.resultLink+]" title="[+as.longtitle+]">[+as.pagetitle+]</a>

            to
              <a class="[+as.resultLinkClass+]" href="[+as.resultLink+]" title="[+as.longtitle+]">[[YAMS? &get=`content` &from=`pagetitle` &docid=`[+as.id+]`]]</a>


            I recieved
            (yams-select:0)(lang:0:en)((yams_data:1:pagetitle_en))(lang:0:fr)((yams_data:1:pagetitle_fr))(/yams-select:0)
            


            Modules>YAMS>Other Params>URL redirection settings>MODx URLs was set on “Current else Browser”.

            So everything works, but not translated titles. I trying to understand how to make YAMS and AjaxSearch templates work together…
              • 22851
              • 805 Posts
              I just did a little investigation. The problem is ajax mode. When the results are obtained via AJAX they are displayed directly, which bypasses the parsing that YAMS normally does when a document is requested. That’s why those YAMS constructs (yams-...)..., which normally get evaluated and return the content in the correct language, just get output instead.

              If you don’t mind giving up ajax mode, then you can solve the problem by setting &ajaxSearch=`0` &AS_landing=`50`. This will display the results on document 50 instead. Those YAMS constructs will be evaluated and will display the content in the correct language.
                YAMS: Yet Another Multilingual Solution for MODx
                YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
                Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.
                • 9670
                • 48 Posts
                Thank you for your help, PMS. I changed first message with description of all steps I has done. Now it works good enough.
                  • 22851
                  • 805 Posts
                  Fil DOrc.

                  Two additional comments:

                  1. &get=`content` still works, but is deprecated. Better to use &get=`data` instead.

                  2. You might want to change [+as.description+] to [[YAMS? &get=`data` &from=`description` &docid=`[+as.id+]`]] too.

                  Paul
                    YAMS: Yet Another Multilingual Solution for MODx
                    YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
                    Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.
                    • 5811
                    • 1,717 Posts
                    The problem is ajax mode. When the results are obtained via AJAX they are displayed directly, which bypasses the parsing that YAMS normally does when a document is requested.
                    I don’t know YAMS, but may be you could use the ajaxSearch stripOutput parameter to parse the results with YAMS.

                    @PMS : I am open to any suggestions, for a better integration between YAMS and AjaxSearch. Don’t hesitate, if you have some suggestions.
                      • 22851
                      • 805 Posts
                      Quote from: coroico at Nov 23, 2009, 10:39 PM

                      The problem is ajax mode. When the results are obtained via AJAX they are displayed directly, which bypasses the parsing that YAMS normally does when a document is requested.
                      I don’t know YAMS, but may be you could use the ajaxSearch stripOutput parameter to parse the results with YAMS.
                      Une très bonne idée !

                      Quote from: coroico at Nov 23, 2009, 10:39 PM

                      @PMS : I am open to any suggestions, for a better integration between YAMS and AjaxSearch. Don’t hesitate, if you have some suggestions.
                      Thank you coroico.
                        YAMS: Yet Another Multilingual Solution for MODx
                        YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
                        Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.