Suggestion for Schedule List range option
-
I am running a hockey league, and like to show “Todays games” (note my prior post on the timezone issue with that) and “Upcoming Games”. I tried the “week” setting (“w”) on the event list shortcode, thinking it would get the coming week, but that gets the current week, meaning that if it’s Friday, it shows all the games from earlier in the week back to Sunday, which is technically correct but not what I intended.
What I really wanted to show the games over the next week, meaning the next 7 days, not the next calendar week.
With one small change to class-sp-schedule.php, i am able to use the range/to/from parameters to get this to work correctly. In the range() function (line 268), you use the DateTime() function to turn the $to into a valid date – so I could put ‘today’ or ‘3 days ago’ and it would work. However, you use the $from value without change. If you change this to use the DateTime() for $from as well, then it makes it possible to use directives like ‘+7 days’.
Here is the code (I also removed the date modify since it was not working as I expected – not sure the ramifications of that):
public function range( $where = '' ) { $to = new DateTime( $this->to ); $from = new DateTime( $this->from ); $where .= " AND post_date BETWEEN '" . $from->format( 'Y-m-d' ) . "' AND '" . $to->format( 'Y-m-d' ) . "'"; return $where; }
Here is the resulting shortcode usage:
[event_list id="105" title="Games in the next 7 days" status="any" date="range" date_from="today" date_to="+7 days" number="" order="default" columns="event,time,teams,venue,league" show_all_events_link="0" align="none" paginated="0"]
Thank you!
- The topic ‘Suggestion for Schedule List range option’ is closed to new replies.