We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17883
    • 1,039 Posts
    Hi coroico,

    The TV are rendered when the searchterms are found in the TV. Try for instance "2007-10" This term exists inside the asTag1. In this case the value is displayed as : 2007-10, Romania, 2007-10, Guatemala, ...

    Ah okay. Just discovered the sample template in the AS snippet folder where the TVs are marked like this:

    <div class="[+as.resultClass+]">
      <a class="[+as.resultLinkClass+]" href="[+as.resultLink+]" title="[+as.longtitle+]">[+as.pagetitle+]</a>
    [+as.descriptionShow:is=`1`:then=`
      <span class="[+as.descriptionClass+]">[+as.description+]</span>
    `+]
    [+as.asTag1Show:is=`1`:then=`
      <br /><br /><div class="[+as.asTag1Class+]"><strong>asTag1=</strong>[+as.asTag1+]</div>
    `+]
    [+as.asTag2Show:is=`1`:then=`
      <div class="[+as.asTag2Class+]"><strong>asTag2=</strong>[+as.asTag2+]</div><br />
    `+]
    </div>


    Thought this would be the template you use in your example.

    Sorry about that, didn`t want to blame your really good explanations ;-)
      • 6848
      • 52 Posts
      Working solution with ajax mode of AjaxSearch (with a lot of dirty patches):

      1. put yams to redirect "current" mode.
      2. change assets/snippets/ajaxSearch/configs/default.config.php and add $dcfg[’tvPhx’] = ’tv:displayTV’;
      In general, don’t relay on configuration in the snippet together with YAMS (I will explain later why)
      3. use snippets like this per language and put them in chunks:

      - bulgarian chunk "ajaxSearch_bg"

      [!AjaxSearch? &tvPhx=`tv:displayTV` &withTvs=`+:content_bg,description_bg,introtext_bg,longtitle_bg,menutitle_bg,pagetitle_bg` &language=`bulgarian` &tplAjaxResult=`ajaxResult_bg.tpl` &tplResult=`result_bg.tpl`!] 


      - bulgarian template ajaxResult_bg.tpl
      <div class="[+as.resultClass+]">
        <a class="[+as.resultLinkClass+]" href="[+as.resultLink+]" title="[+as.pagetitle_bg+]">[+as.pagetitle_bg+]</a>
      [+as.descriptionShow:is=`1`:then=`
        <span class="[+as.descriptionClass+]">[+as.description_bg+]</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>


      Do the same for other languages

      4. call the chunks with:
      [[YAMS &get......]]

      ------------------------
      Now you should have working solution but only for one of the languages. I don’t know for which one, but the reason is folowing:

      Open the source code of one of your pages, which have the search.
      In the head section you will see something like:
      <!-- start AjaxSearch header -->
      <script type="text/javascript">
      //<![CDATA[
      as_version = '1.8.4';
      advSearch = 'oneword';
      subSearch = 5;
      ucfg = ' &withTvs=`+:content_en,description_en,introtext_en,longtitle_en,menutitle_en,pagetitle_en` &tplResult=`result_en.tpl` &tplAjaxResult=`ajaxResult_en.tpl`';
      //]]>
      </script>
      <!-- end AjaxSearch header -->
      
      <!-- start AjaxSearch header -->
      <script type="text/javascript">
      //<![CDATA[
      as_version = '1.8.4';
      advSearch = 'oneword';
      subSearch = 5;
      ucfg = ' &language=`bulgarian` &withTvs=`+:content_bg,description_bg,introtext_bg,longtitle_bg,menutitle_bg,pagetitle_bg` &tplResult=`result_bg.tpl` &tplAjaxResult=`ajaxResult_bg.tpl`';
      //]]>
      </script>
      <!-- end AjaxSearch header -->
      


      As you can see you have 2 AjaxSearch initializations
      (@PMS - this is related to my other post for execution of snippets for all languages, independent on the current)
      This leads to the fact that only the last initialized configuration will work. And it is always the same order, independent on the current language.

      5. To fix this, copy the initialization content per language and put it in separate chunks:

      ajaxInit_bg

      <!-- start AjaxSearch header -->
      <script type="text/javascript">
      //<![CDATA[
      as_version = '1.8.4';
      advSearch = 'oneword';
      subSearch = 5;
      ucfg = ' &language=`bulgarian` &withTvs=`+:content_bg,description_bg,introtext_bg,longtitle_bg,menutitle_bg,pagetitle_bg` &tplResult=`result_bg.tpl` &tplAjaxResult=`ajaxResult_bg.tpl`';
      //]]>
      </script>
      <!-- end AjaxSearch header -->


      do similar chunks for other languages

      6. Call these chunks with [[YAMS? &get......]] just before you call the real AjaxSearch chunks (or include the above code in the real chunk)

      See the solution in action at http://bbr.nitbg.com
      If this link is not available (which will be the case in few days) the production site will be http://www.bbr.bg










        • 5811
        • 1,717 Posts
        I don’t really follow the discussions regarding YAMS and AS but ...
        As you can see you have 2 AjaxSearch initializations
        (@PMS - this is related to my other post for execution of snippets for all languages, independent on the current)
        This leads to the fact that only the last initialized configuration will work. And it is always the same order, independent on the current language.
        Keep in mind that the current AS release (1.8.4) manage only one AjaxSearch input per document. So if you have several AS call (and then an ajaxSearch javascript header), only the last one will taken into account by the js code.

        The release 1.9 in developpement (beta coming soon) may be will allow several AS calls on the same document ...
        For the moment the feature "Several AS instances on a same page" has not a great score ... laugh but the poll is always opened grin
          • 6848
          • 52 Posts
          @coroico
          In my case multiple initializations are not wanted, they are side effect of YAMS/MODx parsing of snippets.
          Multilingual content is organized with replacing document fields with "multilingual" TVs, which is great idea.
          But currently all fields are processed independent of the current language, which means all snippets which are "language dependent" are executed as many times as number of languages you have.
          And if the snippet has calls like:

          $modx->regClientStartupScript($jsVars);

          this will put the result in the page many times.

          So, for the moment the solution with AjaxSearch is to include proper initialization once more after the initializations produced by AjaxSearch snippet calls.
            • 25483
            • 741 Posts
            What’s the solution to go with if I don’t want to use the Ajax mode, but just a landing page which shows me the results?
              with regards,

              Ronald Lokers
              'Front-end developer' @ h2o Media

              • 5811
              • 1,717 Posts
              A demo with several AS snippet call is available on these demo pages - non ajax mode demo - ajax mode demo (mootools) -

              By using the language tag "bg, fr, es, .." you could easily distinguish the ajaxSearch snippet calls and avoid the mess between the jsVars initialisation.

              The Js variables initialization has changed. So now, you could have as many ajaxSearch calls you want. Hereafter, the demo example.
              //<![CDATA[
              asvar[asvar.length]='{"as_version":"1.9.0","advSearch":"oneword","subSearch":"","ucfg":"&asId=`as2` &category=`articleCategory` &parents=`24` &showMoreResults=`1` &moreResultsPage=`203` "}';
              //]]>

                • 22851
                • 805 Posts
                So you can now use [tt]&asId=`(yams_id)`[/tt]. Brilliant. Thanks 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.
                  • 10313
                  • 375 Posts
                  Hi!

                  I’m trying to use YAMS and AjaxSearch together, without actually using Ajax. I have followed the steps from the original post in this thread. But, when I enter my search phrase and hit "enter", i get a blank page (HTML Validator says "End of document in prolog").

                  If I change the name of my [tt]AS_Results[/tt]-chunk to a different name (leaving the AS-call on the landing page unchanged), so that the results page won’t find the chunk, then I get shown the correct number of pages (all well included in my resource template) where my search phrase was found.

                  Any idea what’s going wrong here?

                  Thanks
                  Martin
                    • 10313
                    • 375 Posts
                    Okay, I have narrowed my problem down.

                    If I replace the [tt][+as.resultLink+][/tt] by for example "linkurl" in the result template, then it works fine (up to the links, wich are obvously incorrect.

                    As soon as I use [tt][+as.resultLink+][/tt] again, I get the empty landing page.
                      • 22851
                      • 805 Posts
                      I don’t know why that particular placeholder is creating a blank page. Perhaps you can avoid it and generate a valid multilingual URL by using [tt](yams_doc:[+as.id+])[/tt] instead?
                        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.