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

    I want to exclude from menus in non-standard language monolingual documents.
    I think I can achieve this with a little snippet inside the &rowTpl that checks document template and language Id, but I’d like a better solution, because when you want to change the template you must modify the snippet. As a result we have one snippet for each rowTpl and similar... So I really don’t like this solution.

    I achieved this in Ditto using the filter parameter, but my Ditto calls were in the content of the document, so I just filtered documents using monolingual templates in non-standard languages. This time my Wayfinder calls are in templates.

    Thanks in advance.

    Cheers,

    Roberto
      • 22851
      • 805 Posts
      The way it works at present, monolingual documents are treated as having no specific language and so appear as links in multilingual documents of all languages.

      Ideally we’d need to have a way of telling Wayfinder to exclude the template output for monolingual documents in non-default languages, but since that’s not possible we’ll need to to it ourselves. I’ve been thinking about how this could be done. I don’t think it’s possible to do this using YAMS only unless I were to define some new multilingual constructs.

      In the meantime I think that it might be possible to achieve what you want if you are prepared to install and use PHx. It’s vital that YAMS is configured to come before PHx in the event execution order.

      The idea is to use this in your Wayfinder template...
      [+phx:if=`(yams_id)`:is=`(yams_id:[+wf.docid+])`:then=`
      
      ...normal template stuff goes here...
      
      `:else=``+]


      First Wayfinder will evaluate its placeholders, so the [+wf.docid+] will become the id of the document. Then YAMS will evaluate its placeholders. (yams_id) will evaluate to the id of the language of the document containing the Wayfinder snippet, or the default language id if its monolingual document. Likewise (yams_id:[+wf.docid+]) will evaluate to the id of the language of the menu item document, or the default language id if its monolingual document. So, if both documents are multilingual documents I think they should evaluate to the same language id, but if the menu item document is monolingual then they will only be the same when the wayfinder snippet document is in the default language. I think that’s what we need.

      I have only just thought this idea up, so it’s completely untested and may not work! 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.
        • 25260
        • 156 Posts
        Sorry if I’ve never answered to you.

        I didn’t have time to check your solution, and I don’t like PHx as well :-D

        By the way, we switched to production so I can’t take and test it for the moment.

        We will have a sandbox copy of our site in a few days, then I’ll try to install PHx and see what I can done.

        Cheers,

        Roberto
          • 22851
          • 805 Posts
          No problem Roberto. I’d prefer it if it’s not necessary to use PHx too. When I find the time I’d like to introduce a couple of new YAMS constructs. Something like:
          (yams-exclude-when:...logical stuff...)
          ...
          (/yams-exclude-when)
          and
          (yams-include-when:...logical stuff...)
          ...
          (/yams-include-when)
          which would help to do this without PHx.
            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.
            • 25260
            • 156 Posts
            There’s another thing that comes to my mind.

            YAMSifying Wayfinder templates is causing (at least for me) standard document variables such as pagetitle, menutitle and so on to never be used, even with monolingual templates.

            Just to explain: I make a new resource, I give it a monolingual template, I write menutitle and pagetitle and save. Then I look in frontend and a new item is added to menus, but no data is displayed. So I switch to a multilingual template, fill data in it, save, switch back to monolingual, and then in menus data that I inserted in YAMS TVs is displayed.

            Maybe you have to look at YAMS class or YAMS snippet to solve this, I don’t know.

            Btw this is strange, because if a template is monolingual, YAMS TVs are disconnected from it, but YAMS seems to ALWAYS retrieve data from them.

            Cheers,

            Roberto
              • 25260
              • 156 Posts
              I solved the

              I want to exclude from menus in non-standard language monolingual documents.

              by modifying the Wayfinder snippet.

              Now I’m trying to solve the issue that I pointed out in my last post by writing a mini-snippet that checks the template before retrieving data.

              Cheers,

              Roberto
                • 22851
                • 805 Posts
                Hi Roberto.

                Yes. I’m afraid you’re right about [[YAMS? &get=`data` &from=`field` &docid=`...`]]. It only grabs info from multilingual template variables, whether or not the document is multilingual or not. Until I can update YAMS to correct this, you might be able to use the (yams_multi) placeholder that’s available in the latest development snapshot of YAMS in your snippet. Something like
                [[mysnippet? &multilingual=`(yams_multi:[+docid+])` &langid=`(yams_id:[+docid+])` &docid=`[+docid+]`]]

                should give you all the information you need to determine which field to get the information from. Within the snippet $multilingual will have the value 0 or 1.
                  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
                  Hi again Roberto.

                  I have updated my development version of YAMS (YAMS 1.2.0 RC3) to fix the problems you encountered above. A custom snippet should no longer be required. In the new version:


                  • The [tt]((yams_data:...))[/tt] placeholder now works with document variables in addition to template variables. As with template variables, if multiple placeholders occur on a single document requesting info from different documents this will be done with a minimal number of mysql queries for efficiency.
                  • [tt][[YAMS? &get=`data` ...]][/tt] snippet calls (use within Wayfinder templates for example) will now correctly output data from the document variable fields for monolingual documents rather than default language template variables.
                  • The [tt][[YAMS? &get=`content` ...]][/tt] snippet call is now officially deprecated.

                  I’d be grateful for feedback if you get the chance to try this out. Cheers.
                    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.
                    • 25260
                    • 156 Posts
                    I’ll be at work on Tuesday, so you’ll have to wait a couple of days.

                    Thanks for your work,

                    Roberto
                      • 25260
                      • 156 Posts
                      This is really good PMS. I really really have to say "Thank you" smiley

                      Now everything is working fine, I modified the Wayfinder snippet in order to exclude monolingual documents from non-standard language menus, and with your modifications to the YAMS snippet now it’s retrieving data correctly.

                      Now I have a little problem with Ditto.

                      In some Ditto calls of my site, I can’t pass the filter parameter like this

                      &filter=`[[YAMS? &get=`text` &from=`it::||en::template,15,2`]]`


                      because I can’t set the external Ditto snippet call to be uncached.

                      I took a little look at the YAMS snippet code, and I saw that it outputs some kind of (yams-select) placeholder that are parsed by the YAMS parser.

                      I was wondering if I could write this placeholders direct in the filter parameter, bypassing the YAMS snippet passage, or if I can modify the Ditto extender to automatically exclude monolingual documents in non-standard language.

                      Please anwser having in your mind that I have a sort of fallback converting this Ditto calls to Wayfinder calls, in which I don’t have any problem.

                      Cheers,

                      Roberto