We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44437
    • 74 Posts
    random_noob Reply #1, 9 years ago
    Hello forum,

    I would like some suggestions on how to build upcoming events using modx. I have started it already but quickly noticed some flaws in my logic. This is what I am trying to achieve.


    • Using Collections, Create a container which holds all of events (past, present, future).
    • Each event will be a resource (type document), So that I can enter the event's title, date, location, content, etc
    • Using getResources, display the latest upcoming event and have a countdown timer display it. (I'm currently using a jquery plugin for the countdown timer. It works... sorta)
    • Once the latest event time has elapsed, automatically display the next upcoming event using the previously mentioned getResources.

    I tried using the latest unpublish date to show the latest upcoming event and it worked. However, I realized quickly that I will need that resource to be published and possibly archived for online viewing.

    Does anyone has any suggestions or recommendations?

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

    • discuss.answer
        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
        • 14646
        • 8 Posts
        Jonathan Haslett Reply #3, 9 years ago
        Collections will work great for this.

        Add a TV to the event that has the Time/Date for when the event starts.

        Then could use
        &tvFilters=`tvEventStartDate`
        and
        &limit=`1`
        on
        !getResources
        to return only the next upcoming event.
          Jonathan Haslett
          Director at https://dash.marketing/
          MODX Slack @jonathanhaslett
        • Hm. I'd be inclined to use an extended resource object with the start date and the end date built-in, it would be a lot faster and easier to deal with than using TVs. Collections shouldn't have any trouble handling these. To simplify usage, I'd probably create an empty one, unpublished, and just duplicate it whenever I want to add a new one.

          http://bobsguides.com/blog.html/2014/06/02/why-extend-modresource/
          http://bobsguides.com/classextender-class.html

            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
            • 44437
            • 74 Posts
            random_noob Reply #5, 9 years ago
            Thank you guys for your suggestion. I will try these methods out.
              • 44437
              • 74 Posts
              random_noob Reply #6, 9 years ago
              Hey, I tried out Bruno's tutorial and I'm amazed how powerful Migx can be. What I need to do now is to grab the server's date and compare it to the event's start date TV.

              This is for the countdown timer.

              My Logic is: if (startdate > serverdate) then display this resource (sorted ASC)

              I tried this using getResources TV Filters but it is not working.

              [[getResources@eventslist?
                 &tvFilters=`eventstart>>[[!time:date=`%Y-%m-%d %T`]]`
              ]]


              My Time Snippet

              <?php
              return time();


              Suggestions? [ed. note: random_noob last edited this post 9 years ago.]
              • That's not my tutorial, that's Bruno's tutorial. Try posting to the MIGX board http://forums.modx.com/board/?board=271
                  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
                  • 44437
                  • 74 Posts
                  random_noob Reply #8, 9 years ago
                  Thanks for the correction Susan and I will try your suggestion.
                    • 4172
                    • 5,888 Posts
                    you will need to call getResources also uncached:

                    [[!getResources@eventslist?
                       &tvFilters=`eventstart>>[[!time:date=`%Y-%m-%d %T`]]`
                    ]]


                    does this work then?
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 44437
                      • 74 Posts
                      Brilliant smiley it works. I have another migx question... which I will ask it in a new post. Why must I call it uncached for it to work?