We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51315
    • 67 Posts
    Trying to filter resources with pdoResources using &where:
          [[pdoResources?
                parents=`1`
                &depth=`1`
                &sortby=`menuindex`
                &sortdir=`ASC`
                &where=`{"date:>=":"[[!getDate]]"}`
                &tpl=`myTpl`
                &select=`id,pagetitle,longtitle,description,content`
                &includeTVs=`date`
            ]]

    [[+tv.date]] has a date input
    [[!getDate]] is a snippet that returns the current day and date

    Looks like there is a date format problem.
    Maybe [[+tv.date]] renders a %e %B %Y kind of time and [[!getDate]] is a Unix Time Stamp?

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

      • 33238
      • 388 Posts
      I think is possible, just print both and compare it, just to see if you are comparing two strings with the same format.
        --
        ysanmiguel.com
        • 51315
        • 67 Posts
        Thanks, finally I found an alternative solution by using tvFilters.

        I am quoting debussy from this post:
        https://forums.modx.com/thread/43727/getresources-to-show-current-and-future-events#dis-post-419669

        First, create a small snippet (I called mine curDate) to return the current datetime string:

        <?php
        return date('Y-m-d H:i:s');


        Then you can use the getResources tvFilters using this snippet:

        Current events:

        [[!getResources?
          ...
          &tvFilters=`myDateTV>=[[curDate]]`
        ]]



        Past events:

        [[!getResources?
          ...
          &tvFilters=`myDateTV<<[[curDate]]`
        ]]

        And this is my pdoResources:
        &tvFilters=`date>>[[curDate]]`
          • 4172
          • 5,888 Posts
          curDate should be called uncached

          [[!curDate]]
          
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 51315
            • 67 Posts
            Thanks
              • 53934
              • 3 Posts
              I have the same problem, with old getResources. With smaller-comparator it displays no resources, with greater than it displays all.

              [[!getResources:default=`<p><i>No entries found...</i></p>`?
                          &parents=`...`
                          &tpl=`...`
                          &tplWrapper=`...`
                          &where=`{"unpub_date:<":"[[+mydate]]"}`
                          &sortby=`{"unpub_date":"ASC"}`
                          &limit=`0`
                      ]]
              


              When I compare unpub_date and mydate with the following modifiers, greater and smaller fit. Just in the where clause of getResources is a problem.
              [[+unpub_date:gt=`[[+mydate]]`:then=`greater`:else=`smaller`]]
                • 4172
                • 5,888 Posts
                which format is
                [[+mydate]]
                ?
                unpub_date is unixtime in the db
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 3749
                  • 24,544 Posts
                  Try adding &includeTVs =`1` to the getResources tag. You may also need &tvPrefix=``. You might have to use &processTVs=`1`, but try without it first.
                    Did I help you? Buy me a beer
                    Get my Book: MODX:The Official Guide
                    MODX info for everyone: http://bobsguides.com/modx.html
                    My MODX Extras
                    Bob's Guides is now hosted at A2 MODX Hosting
                    • 53934
                    • 3 Posts
                    Ok, sorry, that were too few informations.
                    I'm working in a Chunk, called in a Snippet. [+mydate] is not a tv, it's a attribute given to the chunk with the format Y-m-d H:i.

                    So I try to get mydate in unixtime. That could be the error. Thank you so far!
                    • discuss.answer
                      • 4172
                      • 5,888 Posts
                      then try

                      &where=`{"unpub_date:<":"[[+mydate:strtotime]]"}`
                      
                        -------------------------------

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!