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

    Wonder if you could help, this is probably a dumb question but please bare with me I’m a noob to modx and YAMS (liking it though!!):

    I’m looking to create a site that will have multi-lingual and mono-lingual content and have been investigating YAMS.

    I need to have a navigation menu that will only display items if:
    There is content for that menu item in the language of the page currently being viewed (not all content will exist in all languages)

    My wayfinder currently looks like this:

    [[Wayfinder?startId=`0` &outerTpl=`mh.OuterTpl` &innerTpl=`mh.InnerTpl`&rowTpl=`@FILE:assets/modules/yams/tpl/wayfinder/doc/row.tpl` &innerRowTpl=`mh.InnerRowTpl` &firstClass=`first` &hereClass=`selected`]]

    And my InnerRowTpl

    <li[+wf.classes+]>
    <a href="(yams_doc:[+wf.docid+])" title="[[YAMS? &get=`data` &docid=`[+wf.docid+]` &from=`pagetitle`]]">[[YAMS? &get=`data` &docid=`[+wf.docid+]` &from=`menutitle`]]</a>
    [+wf.wrapper+]
    </li>

    If not possible simply to configure the wayfinder, is it possible to test this [[YAMS? &get=`data` &docid=`[+wf.docid+]` &from=`menutitle`]] to see if it has content and only output if it does. Giving the user the ability to control it, by entering a menu title in the language or not....

    Thanks,
      • 22851
      • 805 Posts
      Hi lhanson.

      Since you are going to be using both monolingual and multilingual documents, you will need to make sure you are using my latest release candidate: YAMS 1.2.0 RC3. Prior to that the [tt][[YAMS? &get=`data` ...]][/tt] snippet call wouldn’t correctly grab the data for monolingual documents.

      Currently the only way to incorporate the kind of logic you want is to use PHx. You’ll have to install PHx as a standalone plugin and configure it to execute after YAMS in the plugin event execution order. Then I think you should be able to wrap the content of your Wayfinder templates in code like this:

      [+phx:if=`[[YAMS? &get=`data` &docid=`[+wf.docid+]` &from=`menutitle`]]`:isnot=``:then=`
      
      ...normal template stuff goes here...
      
      `:else=``+]


      I haven’t had time to test it out, but I think it should work.

      In the longer term (not in the next couple of weeks, but not too long after that hopefully) I plan to implement some new YAMS functionality that will make conditional inclusion and exclusion of multilingual content possible 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.
        • 17076
        • 9 Posts
        Hi,

        Thanks for the info.

        I tried the PHX call in the wayfinder template and it appears that wayfinder does not support nested PHX calls.

        Would you happen to know how i go about creating my own menu, not using wayfinder?

        Thanks,
          • 22851
          • 805 Posts
          Quote from: lhanson at Jul 10, 2010, 08:26 PM

          I tried the PHX call in the wayfinder template and it appears that wayfinder does not support nested PHX calls.
          I am confused about this. Firstly, Wayfinder doesn’t parse the PHx. To parse the PHx the PHx plugin needs to be installed and needs to be set to execute after YAMS in the plugin event order. The PHx parser claims to handle nested tags, so theoretically at least this should work.

          When you say it doesn’t work, what actually happens?
            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.
            • 17076
            • 9 Posts
            Hi,

            Yes, PHx is installed as a plugin and set to execute after YAMS onParseDocument.

            I have placed the PHx (if then else) piece in my innerrow template for wayfinder.

            However it would seem that PHx does not process the code?

            [+phx:if=`[[YAMS? &get=`data` &docid=`[+wf.docid+]` &from=`menutitle`]]`:isnot=``:then=`<li><a>[[YAMS? &get=`data` &docid=`[+wf.docid+]` &from=`menutitle`]]</a></li>`:else=``+]


            The result is that I get the PHx code printed to page. The [[YAMS? &get=`data` &docid=`[+wf.docid+]` &from=`menutitle`]] piece is processed and displays the menutitle, however the rest is printed to page as is.

            Thanks,
              • 17076
              • 9 Posts
              Hi PMS,

              Thanks for the help on this. I’ve found the problem I was having, using the modx system error I found that when the PHx plugin was being eval()’d it was failing.

              I revisited the plugin code and realised I’d made a mistake uncommenting the first line //<?php. Noob mistake sad!

              Thanks for your help, the PHx if then else is working perfectly for me.

              Let me know if you do get round to putting the conditional pieces into YAMS.