• 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!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Roch

    (@rochesterj)

    Hi!

    Thanks for reaching out.

    That’s a great idea, and since you’ve made the code change yourself this has a higher change of getting implemented into our plugin. I’ll bring this up in our weekly meeting

    Thanks a lot!

    Kind Regards,
    -Roch

    Thread Starter _drg_

    (@_drg_)

    I wanted to follow up on this with another consideration for you (a change I needed to make). Due to the timezone issue (see my other post on same day), the new DateTime() was not working as expected. I added the timezone to the call to make sure it worked correctly for my installation:

    $to = new DateTime( $this->to, new DateTimeZone( get_option( 'timezone_string' ) ) );
    $from = new DateTime( $this->from, new DateTimeZone( get_option( 'timezone_string' ) ) );
    
    
    • This reply was modified 7 years, 1 month ago by _drg_.
    Thread Starter _drg_

    (@_drg_)

    Oh, and a correction to my initial post. The code is in sportspress/includes/class-sp-calendar.php (not class-sp-schedule.php).

    Roch

    (@rochesterj)

    Hi!

    Thanks a lot for the correction.

    I’ll send this to our team once again. we are working hard on our 2.5 release so it probably won’t get implemented right away, but it’s a great idea still ??

    Thanks!

    Kind Regards,
    -Roch

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Suggestion for Schedule List range option’ is closed to new replies.