We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 11681
    • 98 Posts
    @debussy and others suggest a method of filtering Resources relative to current date. See: http://forums.modx.com/thread/43727/getresources-to-show-current-and-future-events#dis-post-419669

    I've done this, and it works fine:
    &tvFilters=`eventDate>>[[!currentDatetime]]`
    However, I want to further restrict Resources. I want the set of those Resources bearing a date TV three months or less in the future. This does the job, ugly though it may be:
    &tvFilters=`eventDate>>[[!currentDatetime]],eventDate<<[[!currentDatetime:strtotime:add=`7889400`:date=`%Y-%m-%d %H:%i:%s`]]`
    That's right, the average number of seconds in three months is 7889400. Since months vary in length from 28 to 31 days, there is some "jitter" in this quick & dirty approach, but it works well enough for my particular use case.

    By the way, only after careful experiment did I learn about continuing a multi-condition tvFilters string onto a new line. It must be done like this:
    &tvFilters=`eventDate>>[[!currentDatetime]]
                ,eventDate<<[[!currentDatetime:strtotime:add=`7889400`:date=`%Y-%m-%d %H:%i:%s`]]`
    It won't work like this
    &tvFilters=`eventDate>>[[!currentDatetime]],
                eventDate<<[[!currentDatetime:strtotime:add=`7889400`:date=`%Y-%m-%d %H:%i:%s`]]`
    Placement of the comma after the newline is critical.
    [ed. note: halfnium last edited this post 10 years, 11 months ago.]
      I looked just like that in 1964.
      • 44234
      • 219 Posts
      Halfnium,

      I wrote a simple snippet that takes the current date but allows you to 'offset' days/months/years for this exact purpose. I will release it in the near future but let me know if you want it in advance.
        Find me on Twitter, GitHub or Google+
        • 11681
        • 98 Posts
        I planned to do that myself once I got around to it, David, but I would gladly use your work instead.
          I looked just like that in 1964.
          • 44234
          • 219 Posts
          Halfnium, know its been a while but finally released that snippet I mentioned above. Docs include code examples of how to use it with getResources to filter by date. Happy to assist if you have any questions.

          getDate Extra:
          http://modx.com/extras/package/getdate

          Docs & Usage Examples:
          http://rtfm.modx.com/extras/revo/getdate#getDate-getResourcesExamples
            Find me on Twitter, GitHub or Google+