We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38415 ☆ A M B ☆
    • 70 Posts
    Hey there,

    i try to use this in a chunk-tpl for getResources:
    [[+eventdate:strtotime:gt=`[[!currentTime`]]`:then=`YES`:else=`NO`]]


    where eventdate is a TV with input type date and currentTime a snippet that outputs the current unixtimestamp. The getResources snippet is called uncached.

    The problem: the above tag always returns "NO"... even if eventdate is greater than the current time.

    It only works when I call the snippet cached - but that is not a solution since the output gets cached and won't change anymore...

    Is this a bug or do I miss something?
      chsmedien - Digital Marketing Agency
      MODX Professional & Ambassador

      http://chsmedien.com | http://twitter.com/christianseel
      • 22303 MODX Staff
      • 10,725 Posts
      You need the outer tag to be called uncached, if I'm understanding the issue...

      [[!+eventdate: ... ]]
        • 38415 ☆ A M B ☆
        • 70 Posts
        Tried this too, but didn't work. The only working combination was
        [[+eventdate:strtotime:gt=`[[currentTime`]]`:then=`YES`:else=`NO`]]


        but this isn't doing the job, since currenTime is cached.
          chsmedien - Digital Marketing Agency
          MODX Professional & Ambassador

          http://chsmedien.com | http://twitter.com/christianseel
          • 22303 MODX Staff
          • 10,725 Posts
          try using this then to make each iteration get a unique value from currentTime...

          [[currentTime? &unique=`[[+idx]]`]]
            • 38415 ☆ A M B ☆
            • 70 Posts
            Mhh...it works, but then it gets also cached.

            It's wirred that the above things aren't working.


            I now worked around with a custom snippet (that compares to the current time), that I use as a output filter. This works:

            I created a snippet "mygreaterthan" with this content:
            if (strtotime($input) > time()) {
              return 1;
            } else {
              return 0;
            }

            And used this as output filter:
            [[+eventdate:mygreaterthan:is=`1`:then=`YES`:else=`NO`]]
            [ed. note: christianseel last edited this post 14 years, 5 months ago.]
              chsmedien - Digital Marketing Agency
              MODX Professional & Ambassador

              http://chsmedien.com | http://twitter.com/christianseel