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

    I´m building a multilingue website, with Modx plugin Babel. Everthing it´s fine, but now i´m getting a little problem with date outputs, when switching contexts.

    On my two contexts, i´ve setup a Locale context setting:

    Web - locale is en_EN.UTF-8
    pt - locale is pt_PT.UTF-8

    Then i created a little snippet to treat my date output according the context.

    Snippet Code (i´m using it as output filter)
    setlocale(LC_ALL, $modx->getOption('locale'));
    return strftime($options, $input);
    


    Then i´m using this little snippet inside my getresources Tpl

    Getresources Tpl
    <h5>[[+tv.tournament-date:strtotime:date=`%d`]] - [[+tv.tournament-date-end:strtotime:strftime=`%e %B %Y`]] </h5>
    


    The strange thing is, on my web context, the dates are showing as expected on every getresources output, on my pt context just show me fine on the FIRST output item.

    Why? It seems that getresources just treat the date for the first item in the cicle!!!


    Can anyone helpme on this?

    Many thanks in advance

    This question has been answered by legues. See the first response.

    [ed. note: legues last edited this post 12 years, 6 months ago.]
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Call your output modifier uncached.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 16899
        • 284 Posts
        Quote from: sottwell at Mar 25, 2014, 07:36 AM
        Call your output modifier uncached.

        How? I never used an output modifier uncached! How can i do that? Many thanks for your reply!!:)
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Like any MODX tag, just put the ! after the opening [[ tags.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 16899
            • 284 Posts
            Quote from: sottwell at Mar 25, 2014, 08:40 AM
            Like any MODX tag, just put the ! after the opening [[ tags.

            But my snippet name is strtotime and i´m using it as output modifier here:
            [[+tv.tournament-date-end:strtotime:strftime=`%e %B %Y`]]
              • 16899
              • 284 Posts
              Quote from: legues at Mar 25, 2014, 08:46 AM
              Quote from: sottwell at Mar 25, 2014, 08:40 AM
              Like any MODX tag, just put the ! after the opening [[ tags.

              Ok, i did it as you suggest, but nothing it+s solved! sad
              [[!+tv.tournament-date-end:strtotime:strftime=`%e %B %Y`]]
              • discuss.answer
                • 16899
                • 284 Posts
                Hi, i solved the problem, and it was something related with my getresources call:

                With this code it works as exepected!! But the thing was, was working on web context and not in pt context!!!! Well it´s woking now!!!! smiley


                [[!getPage? 
                &elementClass=`modSnippet` 
                &element=`getResources`
                &context=`[[*context_key]]`
                &parents=`[[*id]]`
                &showHidden=`1`
                &limit=`5`
                &includeTVs=`1`
                &tpl=`listing-tournaments-Tpl`
                &locale=`[[++locale]]`
                &sortby=`menuindex`
                &sortdir=`ASC`
                ]]


                Many thanks for your help! smiley
                  • 4172
                  • 5,888 Posts
                  what happens, when you put a snippet like that to the top of your <body>

                  <body>
                  [[setLocale? &debug=`1`]]


                  $locale = $modx->getOption('locale');
                  setlocale(LC_ALL, $locale);
                  $output = !empty($debug) ? $locale : '';
                  return $output;
                    -------------------------------

                    you can buy me a beer, if you like MIGX

                    http://webcmsolutions.de/migx.html

                    Thanks!
                    • 16899
                    • 284 Posts
                    Quote from: Bruno17 at Mar 25, 2014, 09:07 AM
                    what happens, when you put a snippet like that to the top of your

                    [[setLocale? &debug=`1`]]


                    $locale = $modx->getOption('locale');
                    setlocale(LC_ALL, $locale);
                    $output = !empty($debug) ? $locale : '';
                    return $output;

                    Now it outputs pt_PT.UTF-8 as expected!! smiley
                      • 16899
                      • 284 Posts
                      Quote from: Bruno17 at Mar 25, 2014, 09:07 AM
                      what happens, when you put a snippet like that to the top of your

                      [[setLocale? &debug=`1`]]


                      $locale = $modx->getOption('locale');
                      setlocale(LC_ALL, $locale);
                      $output = !empty($debug) ? $locale : '';
                      return $output;

                      Now it outputs pt_PT.UTF-8 as expected!! smiley

                      Thanks a lot to try also to help me!!! wink