We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 31902
    • 342 Posts
    I have a situation whereby the contents within a container are running through a calendar component (eventsCalendar2). It works great. In this system, the date of the event is added through a custom TV called event_date (Input type of Date). The events resources are created and housed within a container (the container also houses and runs the calendar call).

    I'm also taking the resources within the calendar container and am displaying them by way of getResources, appearing in list form, much like blog summary entries. Works great.

    So, the client is now asking about the possibility to have the events that have already passed be displayed (in another blog summary-like list) elsewhere. This would be a 'Passed Events' kind of listing.

    So, I'm wondering if there is a way to get getResources to sniff for events that have event date entries (as entered in the above-mentioned event_date TV) that have already happened (older than today) and display them elsewhere on the page? And, of course, filter out and not display entries that are yet to happen? Maybe some sort of if/then entry within the getResources call somehow?

    Am I asking the impossible?

    Thank you in advance.

    MODx Revo 2.2.2
      • 4172
      • 5,888 Posts
      does this work?

      &tvFilters=`event_date<<[[!now]]`


      snippet 'now':

      return strftime('%Y-%m-%d %H:%M:%S');
      


        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 31902
        • 342 Posts
        It didn't work for me, Bruno17, but no doubt because I'm missing quite a bit of necessary knowledge.

        However, let me alter this question somewhat, since you inspired me to follow a different path.

        Instead of a custom TV, let's say I'm trying to publish a set of resources that have happened in the past, as per the pubilshedon date.

        So, I tried the following, but it didn't work because I'm PHP-challenged. I figured I would create two lists, the first showing only the resources that are yet to come and the second only the resources that have happened in the past. This displayed code is for the first list (don't show events published before today):

        1. The listings call (I'm testing this on a blog-like listing on a test site before I bungle a client's site) looks like this:

        <div id="blog_articles_list">
        [[!getResourcesTag?
          &elementClass=`modSnippet`
          &element=`getResources`
          &tpl=`blogPost`
          &parents=`2`
          &limit=`50`
          &includeContent=`1`
          &includeTVs=`1`
          &showHidden=`1`
          &hideContainers=`1`
          &cache=`0`
          &pageVarKey=`page`
          &tvFilters=`[[!date_past]]`
        ]]
        </div><!--blog_articles_list -->
        
        <hr>
        
        


        Take note of the

          &tvFilters=`[[!date_past]]`


        ...part.

        2. Created a snippet called date_past and added the following comedy:

        <?php
        if( $publishedon = ($publishedon < time())) {
             return NULL;
        }
        


        Not surprised it didn't work because I'm not that level of PHP coder, but hopefully it shows enough to communicate what I'm trying to do. In that listing, I wanted to NOT display anything before a published on date.

        Then, after that listing, I would create another listing that displayed them, utilizing the "opposite code" of what you see. Make sense?

        A bit over my head here, but it would be nice to figure this out.

          • 31902
          • 342 Posts
          I now see that the above strategy is not good. The first list can be controlled by setting an unpublish date on each event, therefore that problem takes care of itself.

          The second list (past dates) still need to be figured out, though.
            • 44234
            • 219 Posts
            You may find the Extra below useful. Docs include code examples of how to use it with getResources to filter by date/timestamp.

            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+