We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25483
    • 741 Posts
    How can I use PHx within Ditto? If I use this:

    [+content:limit=`300`+]


    I get this as output:

    (yams-select:140)(lang:140:en)
    
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse ullamcorper semper augue, vitae feugiat massa tristique laoreet. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aliquam non erat nulla, vitae volutpat e


    So it does cut the text, but it does also add "(yams-select:140)(lang:140:en)". How can I fix this? I really need to use PHx in the Ditto template.


    EDIT:
    And I just discovered that pagination in Ditto is not working, it always get’s back to the default language when you click on the link to go to the next page with results.

    I did set it up like is told in the documentation of YAMS and it create links like this:

    For the default language: http://fake.url/artists.html?yams_lang=en&artists_nl_start=3&artists_en_start=0
    and for the dutch language: http://fake.url/artists.html?yams_lang=nl&artists_nl_start=3

    The one for the default language is working, the one for the dutch language is redirecting to the English pages
      with regards,

      Ronald Lokers
      'Front-end developer' @ h2o Media

      • 22851
      • 805 Posts
      Hi @MediaGuy

      YAMS needs to appear first in the plugin execution order on all events to which it is associated. It will parse all YAMS placeholders and constructs and tidy up any ones it is not able to parse to make the document look ’clean’ before other plugins like PHx do their work or any snippet calls are evaluated by MODx etc.

      The most likely problem is that your plugin execution order is not right, so that your PHx command is truncating a YAMS construct.

      Please try placing YAMS first in the execution order and let me know if that doesn’t work.

      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.
        • 22851
        • 805 Posts

        EDIT: And I just discovered that pagination in Ditto is not working, it always get’s back to the default language when you click on the link to go to the next page with results.

        I did set it up like is told in the documentation of YAMS and it create links like this:

        For the default language: http://fake.url/artists.html?yams_lang=en&artists_nl_start=3&artists_en_start=0
        and for the dutch language: http://fake.url/artists.html?yams_lang=nl&artists_nl_start=3

        The one for the default language is working, the one for the dutch language is redirecting to the English pages

        It works like this: The Ditto pagination extension doesn’t know about YAMS, so it creates standard/monolingual URLs. YAMS will redirect from standard URLs to a multilingual language variant of the URL based on the redirection mode you have set up (See Other Params tab.) You have probably got it set to ’Default’ - which means always redirect to the default language. Try changing it to ’current’. Then the link will display in the same language as the last multilingual page accessed. Then all should be fine. If that works for you, I’ll update the documentation.

        Aside By the way, I have been thinking about it, and I might be able to get rid of or at least greatly reduce all those restrictions on URLs being unique and whether or not server and root names are specified etc. In future you might be able to just do whatever you like, which would be much more friendly. I’ve only got this working in a fluffy way in my head, not on paper or code yet. Watch this space.
          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.
          • 25483
          • 741 Posts
          Quote from: PMS at Aug 20, 2009, 03:13 AM

          Hi @MediaGuy

          YAMS needs to appear first in the plugin execution order on all events to which it is associated. It will parse all YAMS placeholders and constructs and tidy up any ones it is not able to parse to make the document look ’clean’ before other plugins like PHx do their work or any snippet calls are evaluated by MODx etc.

          The most likely problem is that your plugin execution order is not right, so that your PHx command is truncating a YAMS construct.

          Please try placing YAMS first in the execution order and let me know if that doesn’t work.

          Thanks.

          I already did that, so that is not the problem. I’m not sure what is causing the trouble, I also use phx:phpthumb to resize image... that one is working good. But on the other side are images not multilingual.

          Quote from: PMS at Aug 20, 2009, 03:30 AM


          EDIT: And I just discovered that pagination in Ditto is not working, it always get’s back to the default language when you click on the link to go to the next page with results.

          I did set it up like is told in the documentation of YAMS and it create links like this:

          For the default language: http://fake.url/artists.html?yams_lang=en&artists_nl_start=3&artists_en_start=0
          and for the dutch language: http://fake.url/artists.html?yams_lang=nl&artists_nl_start=3

          The one for the default language is working, the one for the dutch language is redirecting to the English pages

          It works like this: The Ditto pagination extension doesn’t know about YAMS, so it creates standard/monolingual URLs. YAMS will redirect from standard URLs to a multilingual language variant of the URL based on the redirection mode you have set up (See Other Params tab.) You have probably got it set to ’Default’ - which means always redirect to the default language. Try changing it to ’current’. Then the link will display in the same language as the last multilingual page accessed. Then all should be fine. If that works for you, I’ll update the documentation.

          Aside By the way, I have been thinking about it, and I might be able to get rid of or at least greatly reduce all those restrictions on URLs being unique and whether or not server and root names are specified etc. In future you might be able to just do whatever you like, which would be much more friendly. I’ve only got this working in a fluffy way in my head, not on paper or code yet. Watch this space.

          Yes! That works smiley
            with regards,

            Ronald Lokers
            'Front-end developer' @ h2o Media

            • 22851
            • 805 Posts
            Quote from: MediaGuy at Aug 20, 2009, 04:00 AM

            Quote from: PMS at Aug 20, 2009, 03:13 AM

            Please try placing YAMS first in the execution order and let me know if that doesn’t work.
            I already did that, so that is not the problem. I’m not sure what is causing the trouble, I also use phx:phpthumb to resize image... that one is working good. But on the other side are images not multilingual.
            I have used YAMS with Jot, which uses PHx extensively and not had problems, so this must be a special case I have not picked up on yet. It’s clear that the problem is with truncation of the content document variable that has been replaced by a YAMS multilingual construct. This must mean that PHx is getting to the content before YAMS, or YAMS is not tidying up properly. The only way for me to fix this is to set up a test case and debug it. I know of another issue that is likely to be related that means that it is not possible to put YAMS placeholders in the parameters of cacheable snippet calls. I have been intending to get around to fixing that for a while. Perhaps I can kill two birds with one stone here. Give me a few days, I’ll see what I can do with regards to fixing this.
              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.
              • 25483
              • 741 Posts
              Quote from: PMS at Aug 20, 2009, 04:20 AM

              Quote from: MediaGuy at Aug 20, 2009, 04:00 AM

              Quote from: PMS at Aug 20, 2009, 03:13 AM

              Please try placing YAMS first in the execution order and let me know if that doesn’t work.
              I already did that, so that is not the problem. I’m not sure what is causing the trouble, I also use phx:phpthumb to resize image... that one is working good. But on the other side are images not multilingual.
              I have used YAMS with Jot, which uses PHx extensively and not had problems, so this must be a special case I have not picked up on yet. It’s clear that the problem is with truncation of the content document variable that has been replaced by a YAMS multilingual construct. This must mean that PHx is getting to the content before YAMS, or YAMS is not tidying up properly. The only way for me to fix this is to set up a test case and debug it. I know of another issue that is likely to be related that means that it is not possible to put YAMS placeholders in the parameters of cacheable snippet calls. I have been intending to get around to fixing that for a while. Perhaps I can kill two birds with one stone here. Give me a few days, I’ll see what I can do with regards to fixing this.

              I also use Jot and that works great. Maybe it is because my Ditto call is cached, the pagination placeholders don’t work if I call it uncached. Not sure why that is because it should just work.
                with regards,

                Ronald Lokers
                'Front-end developer' @ h2o Media

                • 22851
                • 805 Posts
                It shouldn’t just work. To use pagination with ditto you have to call it using an uncacheable snippet call. Otherwise the first page gets cached and displayed every time. It is a general rule that snippets that can output different content on different page loads need to be called as uncahceable [!...!]. EDIT: Alternatively the document as a whole must be set to uncacheable.

                EDIT: Just re-read your post. You say "the pagination placeholders don’t work if I call it uncached". Confused. The ditto call needs to be uncached for the placeholders to work. At least, that’s what I expected and found when I tested pagination with YAMS before. If you continue to have problems I’ll look into it again.
                  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.
                  • 25483
                  • 741 Posts
                  Quote from: PMS at Aug 20, 2009, 04:52 AM

                  It shouldn’t just work. To use pagination with ditto you have to call it using an uncacheable snippet call. Otherwise the first page gets cached and displayed every time. It is a general rule that snippets that can output different content on different page loads need to be called as uncahceable [!...!]. EDIT: Alternatively the document as a whole must be set to uncacheable.

                  EDIT: Just re-read your post. You say "the pagination placeholders don’t work if I call it uncached". Confused. The ditto call needs to be uncached for the placeholders to work. At least, that’s what I expected and found when I tested pagination with YAMS before. If you continue to have problems I’ll look into it again.


                  Well, The document itself is uncacheable, but the Ditto call is cached and works! If I make the Ditto call uncached it stops working. Very strange, I don’t know what is causing this... normally it should not work this way!!
                    with regards,

                    Ronald Lokers
                    'Front-end developer' @ h2o Media

                    • 22851
                    • 805 Posts
                    Quote from: MediaGuy at Aug 20, 2009, 12:16 PM

                    Well, The document itself is uncacheable, but the Ditto call is cached and works! If I make the Ditto call uncached it stops working. Very strange, I don’t know what is causing this... normally it should not work this way!!
                    If the document is uncacheable, then the ditto call wont be cached, no matter whether it is specified with [! or [[. I can’t imagine why it wont work with both document and snippet call specified as uncacheable though. You’re right - it should still work.

                    Optimally, you should have it set-up the other way around by the way. The document should be cacheable, but the snippet call should be set to uncacheable. I’m pretty sure that configuration works, because I have tested it in the past.

                    EDIT: Just to be sure we’re not talking at cross-purposes. It’s [!uncacheable!] and [[cacheable]]
                      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.
                      • 25663 MODX Staff
                      • 12,272 Posts
                      To be fair, I think there may be some discrepancy in how the parser behaves on cached vs uncached pages. Might be worth filing a report in JIRA.
                        Ryan Thrash, MODX Co-Founder
                        Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me