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

    I’m using Evolution 1.0.2, YAMS 1.1.7 alpha RC 8, PHx 2.1.3.

    I try to use Ditto with PHx on my multilingual pages. This does not work correctly. I have read about problems with Ditto and PHx (in combination with YAMS), but I still do not know if my problem is in my code or in YAMS/Ditto/PHx.

    I have followed the Howtos in the YAMS documentation. My "normal" Ditto-template works very good in multilingual context.

    But when I use PHx in the template, it does not work as expected. To tell the truth: I have not yet recognized a pattern of "what works" and what does not.

    Thus, I have edited my template, so that I explicitly use "_(yams_id)" as suffix:
    <div class="artikel">
    [+bild:ne=``:then=`[+introtext_(yams_id):ne=``:then=`<a href="[~[+id+]~]"><img src="[+bild+]" alt="" width="100"/></a>`:else=`<img src="[+bild+]" alt="" width="100"/>`+]`:else=``+]
    <div class="text">
    [+longtitle_(yams_id):ne=``:then=`<h2>[+longtitle_(yams_id)+]</h2>`:else=``+]
    <h1>[+introtext_(yams_id):ne=``:then=`<a href="[~[+id+]~]">`+][+pagetitle_(yams_id)+][+introtext_(yams_id):ne=``:then=`</a>`+]</h1>
    [+introtext_(yams_id):ne=``:then=`<p>[+introtext_(yams_id)+] <a href="[~[+id+]~]">» mehr</a></p>`:else=`[+content_(yams_id)+]`+]
    </div>
    </div>

    It is quite long, because there are case differentiations. If [tt]introtext_(yams_id)[/tt] is set, the template should output the introtext and a link to the content. It the introtext is left empty, the content is output directly. This works very fine for me on many monolingual websites I have created. But not with yams.

    What can I still do? I bet there is a solution. Even it is not too convenient, there must be a solution.

    Thanks in advance
    Martin

    EDIT: I forgot to mention my Ditto call:
    [!Ditto? &tpl=`tplNews` &display=`8` &extenders=`@FILE /assets/modules/yams/yams.extender.inc.php` &id=`(yams_id)` &language=`(yams_mname)` &orderBy=`menuindex DESC` &noResults=` `!]
      • 22851
      • 805 Posts
      FuryDE. You’ve provided enough information for me to be able to set up a test case in YAMS and run it through a debugger. I’ll try to do that in the coming week, or maybe this weekend if you’re lucky.
        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.
        • 22851
        • 805 Posts
        The problem is with using placeholders of the form [tt][+fieldname_(yams_id)+][/tt]. This wont work within a Ditto template since the order in which the Ditto template content gets parsed is:

        1. Ditto Placeholders are evaluated - with the YAMS extension converting document variables to special multilingual constructs containing [tt]((yams_data:...))[/tt] placeholders where necessary) + Then Ditto parses PHx
        2. YAMS This includes evaluation of multilingual constructs and YAMS placeholders, like (yams_id)
        3. PHx

        So, the [tt](yams_id)[/tt] in the [tt][+fieldname_(yams_id)+][/tt] placeholder is not evaluated until after the template is processed by Ditto. Thus the placeholder is not recognized and no content is output.

        The solution is to use the [tt]((yams_data:...))[/tt] placeholder instead like YAMS does. Within the Ditto template this would be implemented like so:

        [tt]((yams_data:[+id+]:fieldname_(yams_id)))[/tt]

        The [tt][+id+][/tt] will be evaluated by the Ditto snippet. The [tt]((yams_data:...))[/tt] placeholders will then end up in the main document template, where the [tt](yams_id)[/tt] and then the [tt]((yams_data:...))[/tt] placeholder will be evaluated by YAMS. Finally, phx will do its work - so you should get the required output.

        EDIT

        Oops. Just realised that Ditto does its own PHx parsing... so my logic above was flawed. I’ve just read that it is possible to turn off Ditto’s PHx [tt]&phx=`0`[/tt] parsing. The documentation doesn’t make it clear whether the PHx brackets are then deleted by Ditto or whether they make their way through to the output. If it’s the latter then the [tt]((yams_data))[/tt] technique above should work.
          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
          Wow, thank you very much for this elaborate answer. I will try this immediately. I think (or better hope) that the Ditto-internal PHx won’t bother me. I have a little patch in the Ditto plugin code that does not load it’s own PHx when it is already loaded. I hope, this works here for me. If not, maybe I have to patch the pathc wink

          BTW: if you use &phx=`0` then no PHx will be parsed.

          EDIT: It is like you were worried about: It does not work, because Ditto does it’s own PHx substitution before YAMS comes into action. Such a pity. I can’t accept that there is no solution, so I’ll be searching on ...
            • 10313
            • 375 Posts
            So this is my solution: I have one Ditto template for each language. Thus, the Ditto call was changed, it is now
            [!Ditto? &tpl=`tplNews_(yams_id)` &display=`8` &id=`(yams_id)` &language=`(yams_mname)` &orderBy=`menuindex DESC` &noResults=` `!]


            Thank you very much for your help. Looking at and thinking over the above parsing order that you showed me it seams to me that there was no other solution.

            Greetings
            Martin
              • 29875
              • 4 Posts
              Hey, I had the same problem and it cost me a whole day trying to find a solution and I have found one.

              First you have turn off Ditto PHx-Substitution via &phx=`0`. Now no phx is done so you have to modify your phx-tags.

              For Example:
              [+content:striptags+]


              Changed that to:
              [*phx:input=`((yams_data:[+id+]:content_(yams_id)))`:striptags*]


              Now the parsing order is correct:
              1. Ditto replaces the [+id+]-placeholder with the current id
              2. YAMS replaces the ((..))-construct with the actual content
              3. PHx executes the striptags-function and outputs the modified content

              For none-multilingual fields like an image-field use:
              [*phx:input=`[+image+]`:phpthumb=`73x110`*]

              That forces PHx to parse the Ditto-Placeholder.

              My Ditto-Call:
              [[Ditto? &parents=`[*id*]` &tpl=`@FILE:assets/templates/list-item.html` &noResults=`Keine Einträge vorhanden` &phx=`0`]]


              Hope that works for you as it works for me.
                • 22851
                • 805 Posts
                That’s brilliant! Thank you for sharing thomasd.

                EDIT: I’ve added it to the YAMS How to? documentation: http://svn.modxcms.com/docs/pages/viewpage.action?pageId=15138852
                  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.
                  • 18174
                  • 116 Posts
                  modx:1.0.4, YAMS 1.2.0 rc2 (also checked with v1.1.9)

                  Ditto Call:
                  [[Ditto? &parents=`72,3`
                  &extenders=`@FILE assets/modules/yams/yams.extender.inc.php`
                  &filter=`kategorie-tag,-1,2`
                  &id=`news`
                  &depth=`0`
                  &tpl=`yams_news_item`
                  &display=`all`
                  &sortBy=`pub_date`
                  &language=`german`
                  &paginate=1
                  &display=3
                  &tplPaginateNext=`newsLinkToMoreYAMS`
                  &phx=0
                  &debug=0]]

                  newsLinkToMoreYAMS Chunk:
                  <a href="[~160~]"> [*phx:input=`(yams_id)`:is=`mehr deutsch`:else=`mehr französisch`*] (yams_id)</a>
                  <a href="[~160~]"> [*phx:input=`(yams_id)`:is=`de`:then=`mehr deutsch`:else=`mehr französisch`*] (yams_id)</a>


                  Problem:
                  (yams_id) inside phx is not recognized, phx returs always `mehr französisch`.
                  The 2nd (yams_id) outside phx is recognized correctly.

                  What’s wrong??

                  Another idea is to make &tplPaginateNext language driven like `newsLinkToMore_(yams_id)`, doesn’t work either.

                  Do I something wrong or is it just a limitation?

                  best regards and thanks for the effort.
                  manu

                  EDIT:
                  Meanwhile I solved it this way:
                  <a href="[~160~]">[[YAMS? &get=`text` &from=`fr::En savoir plus ||de::mehr `]]></a>


                  ..but the question still remains..