Shortcode time queries incompatible with recurring events

WordPress Event Management, Calendars & Registration Forums General Question Shortcode time queries incompatible with recurring events

This topic contains 8 replies, has 2 voices, and was last updated by  Stephen Harris 9 years, 8 months ago.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #10482

    I was really excited about the Event Map shortcode in the Pro version because I planned to use it to make a map that appears on our site when our food truck is out at an event.

    That is, I planned on using [event_map starts_before="now" ends_after="now" no_events="Some placeholder stuff here"] so that a map would appear to show where we are, only when we’re out selling. The problem is that I have a recurring event in my calendar. Its first occurrence starts before now, and its last occurrence ends after now, so it will show up, even when no particular occurrence of it is happening. I’m still pretty new at all this, but it seems like this isn’t something I can fix via any of your documented hooks. Is there any way you could change how the queries work so they don’t return an event if none of its individual occurrences match?

    Thanks again!
    Yoni

    Yoni
    #10484

    Hi Yoni,

    The actual attributes should be event_start_before and event_end_after. (The attributes are exactly those supported by the event list shortcode). With the attributes corrected, the query should be only for events which start before now and end after now (i.e. events which are currently running).

    Stephen Harris
    #10485

    Sorry, I meant to double-check the specifics before I posted that example, but I had the attributes named correctly on my test page. It still shows a recurring event that isn’t currently running. Turns out this only happens with the event_map shortcode. The eo_events (Events List) shortcode works fine with the same attributes.

    Yoni
    #10512

    Hi Yoni,

    Apologies for the delay getting back to you. I did some digging into this at it seems that there is a bug in eo_get_events() where it converts relative date formats into actual dates: it ignores the time part.

    The code in question is a duplication of code which happens later on (which is why the event list shortcode, which uses WP_Query(), works as expected). I shall be adding additional unit tests to make sure that address this bug does provide intended behaviour before releasing it, but if you wish to implement the fix now you can do so by deleting lines 120-125 of includes/event-organiser-event-functions.php (the code highlighted here)

    Stephen Harris
    #10609

    Oh cool. Somehow I got unsubscribed from this post so I didn’t see it until just now, but I’ll give this a go!

    Yoni
    #10612

    Ok, related question: is there any reason you don’t use html_entity_decode on $atts[‘no_events’] to allow html use in the replacement text? I was thinking of trying to edit the plugin source myself to add that, but I couldn’t find where the [event_map] shortcode’s handler actually prints that text.

    Yoni
    #11550

    HTML in shortcode attributes is problematic (from a user’s perspective). For more advanced editing the best way is to go down the route of using pre-defined templates.

    Stephen Harris
    #11640

    Yeah, I’ve done a little Googling and found that there seems to be a consensus that html and shortcodes don’t really mix. So while it seems like it’d be super handy to use html in the no_events attribute, I get why you made the decision.

    I guess if I really want to use an HTML placeholder, I should use a conditional in a template? That is: call eo_get_events() with the same query parameters, then if it’s empty display the HTML and if it has any results just use do_shortcode(). Does that sound right?

    Thanks,
    Yoni

    Yoni
    #11641

    Hi Yoni,

    Unless you loose the ‘placeholder tags’, the plug-in uses a template file (shortcode-event-list.php) to display events, I’d recommend simply editing that to include the desired HTML mark-up for “no events”. (See this page for more info)

    Stephen Harris
Viewing 9 posts - 1 through 9 (of 9 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.