We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22851
    • 805 Posts
    EDIT: This solution doesn’t work I’m afraid... It just pretended to work when I tested it the first time.

    @Fil DOrc, please can you test the following for me?

    1. Download and unzip yams.ajaxsearch.config.inc.zip.

    2. Save the file to assets/modules/yams/snippets/ajaxsearch/yams.ajaxsearch.config.inc.php. (You’ll have to create the directory.)

    3. Add
    require_once( $modx->config['base_path'] . 'assets/modules/yams/snippets/ajaxsearch/yams.ajaxsearch.config.inc.php' );

    to your ajaxsearch config file. By default this is located at assets/snippets/ajaxSearch/configs/default.config.php.

    4. Either add &stripOutput=`asParseYAMS` to your AS snippet call, or if you are already using a custom stripOutput function, make
    $results = asParseYAMS( $results );
    its first line.

    5. Finally, set &ajaxSearch=`1`.

    I think that should provide you with a fully working solution. Please let me know how it goes.
      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.
      • 17883
      • 1,039 Posts
      Hi PMS,

      I tried it, but got these error messages above my results:
      Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /home/aurelius/htdocs/aurelius.ve.m-online.net/neu/assets/modules/yams/class/yams.class.inc.php


      If I try to get the multilingual pagetitle I get:
      (yams-select:333)(lang:333:en)((yams_data:72:pagetitle_en))(lang:333:de)((yams_data:72:pagetitle_de))(/yams-select:333)


      I think the Snippet isn`t executed. This is my result chunk:

      <div class="[+as.resultClass+]">
      <a class="[+as.resultLinkClass+]" href="[+as.resultLink+]" title="[+as.pagetitle+]">[[YAMS? &get=`data` &from=`pagetitle` &docid=`[+as.id+]`]]</a>
      [+as.extractShow:is=`1`:then=`
        <div class="[+as.extractClass+]"><p>[+as.extract+]</p></div>
      `+]
      </div>


      And my AS-call:
      [!AjaxSearch? &addJscript=`0` &jscript=`mootools1.2` &tplAjaxResult=`AS_Result` &liveSearch=`1` &stripOutput=`asParseYAMS` &showMoreResults=`1` &moreResultsPage=`1` &withTvs=`content_(yams_id),longtitle_(yams_id),menutitle_(yams_id),pagetitle_(yams_id)` &language=`(yams_mname)`!]

        • 22851
        • 805 Posts
        Quote from: MadeMyDay at Nov 24, 2009, 12:30 PM

        I tried it, but got these error messages above my results:
        Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /home/aurelius/htdocs/aurelius.ve.m-online.net/neu/assets/modules/yams/class/yams.class.inc.php


        Hi @MadeMyDay. Is any indication given about which line within yams.class.inc.php the problem is encountered? Thanks.
          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.
          • 17883
          • 1,039 Posts
          Hi PMS, sorry, I missed the last line of the error:

          Warning: array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object in /home/aurelius/htdocs/aurelius.ve.m-online.net/neu/assets/modules/yams/class/yams.class.inc.php on line 6706
            • 22851
            • 805 Posts
            Hi there.

            I’m afraid the stripOutput ’solution’ I suggested earlier doesn’t actually work... and I can’t find a way to easily get it to work.

            I have come up with a fairly simple idea for an alternative solution which should work with AJAX... but I haven’t succeeded in implementing it yet. I just get blank output instead of the multilingual template variable output. Perhaps coroico might have an idea what I am doing wrong? Could it be that I need to refer to the template variables with the tv234 style tv naming convention rather than using their full names?

            My idea is as follows:

            1. Add the [tt]&tvPhx=`tv:displayTV`[/tt] parameter to the snippet call. This should make the multilingual template variables available as placeholders. Something like [tt][+as.longtitle_en+][/tt], [tt][+as.description_en+][/tt], etc.

            2. Create one [tt]ajaxResult_langId[/tt] template chunk for each language, [tt]langId[/tt]. In each template chunk, use placeholders which access the multilingual tvs for that language. Something like:
            <div class="[+as.resultClass+]">
              <a class="[+as.resultLinkClass+]" href="[+as.resultLink+]" title="[+as.longtitle_fr+]">[+as.pagetitle_fr+]</a>
            [+as.description_frShow:is=`1`:then=`
              <span class="[+as.description_frClass+]">[+as.tvDescription_fr+]</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>
            


            3. Finally, instruct AjaxSearch to use the correct language result template by adding [tt]&tplAjaxResult=`ajaxResult_(lang_id)`[/tt] to the snippet call.

            @MadeMyDay. If you don’t have success with this approach, then I am afraid that the only option is to fall back to non-ajax mode and have the result displayed on a separate page. In that case it is fine to replace the standard document variable placeholders like [+as.pagetitle+] with a YAMS snippet call like [[YAMS? &get=`data` &from=`pagetitle` &docid=`[+as.id+]`]].
              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.
              • 17883
              • 1,039 Posts
              I have come up with a fairly simple idea for an alternative solution which should work with AJAX... but I haven’t succeeded in implementing it yet.

              Neither do I. Also on the wangba demo site it doesn`t seem to work, there are no TVs rendered. This definitely would be the best and simple solution...

              I also thought of a custom Snippet like the YAMS one to render the pagetitle. Shouldn`t that work? Like [!getpagetitle?id=`[+as.id+]` &lang=`(yams_id)`!]? And the snippet only reads the templatevaroutput of that lang and id?
                • 22851
                • 805 Posts
                Quote from: MadeMyDay at Nov 25, 2009, 12:37 PM

                I also thought of a custom Snippet like the YAMS one to render the pagetitle. Shouldn`t that work? Like [!getpagetitle?id=`[+as.id+]` &lang=`(yams_id)`!]? And the snippet only reads the templatevaroutput of that lang and id?
                When the ajax request is made, it doesn’t include any information about the document id or current language of the page that made the request and no YAMS parsing is done... so (yams_id) wont be evaluated. You should be able to do the following within your snippet call though:
                global $modx;
                require_once( $modx->config['base_path'] . 'assets/modules/yams/class/yams.class.inc.php' );
                $yams = YAMS::GetInstance();
                $lang = $yams->GetCurrentLangId();
                
                // ... getTemplateVarOutput...
                


                Any YAMS stuff within the pagetitle wont be parsed... but normally you wouldn’t go including YAMS snippets etc. within the pagetitle anyway.
                  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.
                  • 17883
                  • 1,039 Posts
                  I will try that! Thx Paul!
                    • 17883
                    • 1,039 Posts
                    Works like a charme!

                    Snippet "getASfield":

                    <?php
                    global $modx;
                    require_once( $modx->config['base_path'] . 'assets/modules/yams/class/yams.class.inc.php' );
                    $yams = YAMS::GetInstance();
                    $lang = $yams->GetCurrentLangId();
                    $field = isset($field) ? $field : 'pagetitle';
                    $langField = $field.'_'.$lang;
                    $output = $modx->getTemplateVarOutput($langField,$docId);
                    return $output[$langField];
                    ?>


                    Call like in my template:

                    <div class="[+as.resultClass+]">
                    <a class="[+as.resultLinkClass+]" href="[+as.resultLink+]" title="[+as.pagetitle+]">[!getASfield? &field=`pagetitle` &docId=`[+as.id+]`!]</a>
                    [+as.extractShow:is=`1`:then=`
                      <div class="[+as.extractClass+]"><p>[+as.extract+]</p></div>
                    `+]
                    </div>


                    Paramaters:

                    &docId=`[+as.id+]` : The id of the found doc (don`t change that, is filled by AS)
                    &field: The field to retrieve the YAMS value from (pagetitle, longtitle and so on)

                    Thanks Paul!
                      • 5811
                      • 1,717 Posts
                      About tvPhx and the display of TVs. About this remark :
                      Neither do I. Also on the wangba demo site it doesn`t seem to work, there are no TVs rendered.
                      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, ...

                      Nevertheless, I recognize that this demo is not well explained and the drop down list not very accurate tongue

                      Futher explanations on this topic. (I wouldn’t polluate the YAMS board with ajaxSearch explanations).