We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 53177
    • 14 Posts
    I'm trying to list some content by month based on a "start_date" TV. I'm having a bit of a problem, and I'm sure this is a simple problem, and I'm just not seeing the answer.

    I have a list of content that contains a start date and end date (in a TV: event_start_date and event_end_date)

    I want to do list the content in chunks by month. So

    MAY
    -- content - event_start_date contains events from MAY

    JUNE
    -- content - event_start_date contains events from JUNE

    JULY
    -- content - event_start_date contains events from JULY

    If there is no content for that month, it can stay blank.

    My getResources call (to pull everything in is pretty standard:

                            
    [[!getResources?
        &parents=`36`
        &tpl=`upcoming-event-list-element`
        &includeContent=`1`
        &includeTVs=`1`
        &sortbyTV=`event-start-date`
        &sortdir=`ASC`
     ]]
     


    Can someone tell me how to filter event_start_date by month?
      • 54199
      • 108 Posts
      You need 2 cycles:

      1. Get all the values of "event-start-date" with getResources and build months structure.
      2. In each result put another getResources and filter out the necessary resources with where. This is simple way, but slow and bad practice.

      However, i advise you to create your own snippet and build data structure with xPDO, this requires some knowledge of php. Contact me for help (it's free).
        • 53177
        • 14 Posts
        Quote from: argonaut2k at May 20, 2018, 09:31 PM

        However, i advise you to create your own snippet and build data structure with xPDO, this requires some knowledge of php. Contact me for help (it's free).

        I figured this would require some custom coding, though I was really hoping that through "Archivist" or some such, you could specify the TV to filter through.

        I would solicit your help, and I definitely appreciate the "It's Free" part, as this is a budgetless project I am doing for a friend (a church website). Unfortunately, I am not a PHP programmer... and I respect programmer's time enough to not ask for their help for free... however, if you really are willing to give me some simple advice, please PM me and I'll give you a backend link to the site.

        I did find a workaround, by simply creating a MONTH field from which he can choose a month to filter the event by. Though I AM having a hard time filtering by day, and no matter what I try, I can't seem to filter the event to INCLUDE today (It will filter all future events, but not dates greater than OR equal to). This is the line (getResources) I'm using:

        &tvFilters=`listing_month==[[!getDate:date=`%B`]],event_end_date>=[[!getDate:date=`%Y-%m-%d %H:%M:%S`]]`

        This (obvously) uses the MONTH field I created and compares it to today's month... but the END date won't validate to dates equal to or greater than (>=), ONLY greater than. Working with DATES is a huge pain in the [bloop!]

        I was hoping there would be a much better CALENDAR extra for Modx, but nothing seems to fit even this simple bill and MXCalendar seems to have self-destructed (it was my only hope).

          • 54199
          • 108 Posts
          Quote from: gaslampvillage at May 21, 2018, 05:48 PM
          Quote from: argonaut2k at May 20, 2018, 09:31 PM

          However, i advise you to create your own snippet and build data structure with xPDO, this requires some knowledge of php. Contact me for help (it's free).

          I figured this would require some custom coding, though I was really hoping that through "Archivist" or some such, you could specify the TV to filter through.

          I would solicit your help, and I definitely appreciate the "It's Free" part, as this is a budgetless project I am doing for a friend (a church website). Unfortunately, I am not a PHP programmer... and I respect programmer's time enough to not ask for their help for free... however, if you really are willing to give me some simple advice, please PM me and I'll give you a backend link to the site.

          I did find a workaround, by simply creating a MONTH field from which he can choose a month to filter the event by. Though I AM having a hard time filtering by day, and no matter what I try, I can't seem to filter the event to INCLUDE today (It will filter all future events, but not dates greater than OR equal to). This is the line (getResources) I'm using:

          &tvFilters=`listing_month==[[!getDate:date=`%B`]],event_end_date>=[[!getDate:date=`%Y-%m-%d %H:%M:%S`]]`

          This (obvously) uses the MONTH field I created and compares it to today's month... but the END date won't validate to dates equal to or greater than (>=), ONLY greater than. Working with DATES is a huge pain in the [bloop!]

          I was hoping there would be a much better CALENDAR extra for Modx, but nothing seems to fit even this simple bill and MXCalendar seems to have self-destructed (it was my only hope).


          We will find the best solution smiley Please contact me at [email protected]