WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Long events display using shortcodes (22 posts)

  1. gabejamison
    Member
    Posted 2 years ago #

    Hey everyone, I'm using shortcodes to display a specific category of events, but I'm having a little problem. My events in this category last for several months. I'm trying to separate them out using these event date ranges (Current, Future, Past). I was able to get current and past working using scope="today" and scope="past" respectively, my problem is with the future scope. The future scope doesn't use the start date, as far as I can tell, because it is showing current events that end in the future. I'd like it to only show events that haven't started yet. I've tried scope="today+1" and scope=">today" which both break and just display all events. Anyone have an idea how I can display a group of events that haven't started yet?

    http://wordpress.org/extend/plugins/events-manager/

  2. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    There's a setting for that in settings - Are current events past events?

  3. gabejamison
    Member
    Posted 2 years ago #

    Yeah I know about that setting, but I was speaking of current events that last for several more months. I didn't want them to show up as current events and future events (because of the end date). I created a new scope however and I was able to achieve what I wanted.

    add_filter( 'em_events_build_sql_conditions', 'my_em_scope_conditions',1,2);
    function my_em_scope_conditions($conditions, $args){
    	if( !empty($args['scope']) && $args['scope']=='future-start' ){
    		$start_date = date('Y-m-d');
    		$conditions['scope'] = " (event_start_date > CAST('$start_date' AS DATE))";
    	}
    	return $conditions;
    }
    add_filter( 'em_get_scopes','my_em_scopes',1,1);
    function my_em_scopes($scopes){
    	$my_scopes = array(
    		'future-start' => 'Future Start'
    	);
    	return $scopes + $my_scopes;
    }

    Then I called [events_list scope="future-start" category="2"]
    and was able to only pull future events that have not started yet.

  4. agelonwl
    Member
    Posted 2 years ago #

    thanks for sharing!

  5. Shonu
    Member
    Posted 2 years ago #

    I think I have a use for this code as well!
    Thanks!

  6. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    thanks for sharing, but isn't that what setting I mentioned do this?

    that setting should only consider events as current if the start date is later than your search day, i.e. they haven't already started.

  7. Shonu
    Member
    Posted 2 years ago #

    Perhaps it should not always be global....?
    But yes, globally, your settings would do the job.
    My recurring event problems are much more complex as you know ;-) and a recent post even wants long events with different times per occurrence...

  8. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    confused, what do you mean by global?

  9. Shonu
    Member
    Posted 2 years ago #

    EM Settings are global for events listing. With shortcodes you sort of create your own events lists, overriding the default/global of the settings, right ?

  10. gabejamison
    Member
    Posted 2 years ago #

    Marcus,
    I have "Are current events past events" set to no. But current events still show up as future events (when the end_date is after today), so I'm not sure if that's what you wanted the plugin to do, or maybe I am not being clear in what I was trying to do.

    My list of events:
    Event 1: Start two months ago, end yesterday (past)
    Event 2: Start yesterday, end two months from now (past, current & future)
    Event 3: Start tomorrow, end two months from now (future)

    I wanted to list these events in groups according to when they occur (Current, Future, and Past)

    Before my list looked like this:
    Current Events
    Event 2
    Future Events
    Event 2 (shouldn't show up here, because it is a current event)
    Event 3
    Past Events
    Event 1

    Event 2 did not show up as a Past Event because I have the "Are current events.." setting set to no, but it still showed up under Future Events. I created the scope setting, and was able to display only events that have not started yet as Future Events.

  11. Shonu
    Member
    Posted 2 years ago #

    Event 2 reaches in the future and that is why it is possibly marked also as future. It would help if there would be a clear "running" or current events definition. Event 2 should not be repeated as future event as the start date is passed (cannot book anymore), I agree .

  12. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    @Shonu, i see what you mean. could probably make this an attribute eventually

    @gabejamison
    maybe it's a bug, i would think that setting 'are current events past' to yes would remove #2 from future events, as it already started and is therefore past.

    will check it out

  13. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    @gabejamison
    Just tested this, if I make an event start in the past and end in the future, if you show a list of future events and flick that setting on/off, the event disappears accordingly.

    could it be you've altered the SQL making your own changes?

  14. gabejamison
    Member
    Posted 2 years ago #

    @Marcus
    I haven't changed the SQL statements. But I wonder, will Event 2 now show up under Current Events and Past Events? All these lists are on one page so any duplication would be awkward. My idea of current is today or right now regardless of when it started or stops. Otherwise if it's not happening today it should be defined as past or future. I can test your suggestion later today.

  15. gabejamison
    Member
    Posted 2 years ago #

    @Marcus
    I tried it with "are current events..." set to Yes, and the results were a little worse than expected, the events were not displayed as Current Events and only in Past Events. It's really okay though, I got it working with my custom scope so hopefully if anyone else runs into the same issue they can use my code to help out.

    Maybe in a future release you can address the issue if enough people are looking at doing the same thing. For me anyway:
    Past = Started in the past, ended in the past
    Current = Happening right now, regardless of when it started or ends
    Future = Has not started or ended.

    I know these definitions are general and may not apply to everyone, but they might help get a conversation going on the subject.

  16. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    will test this again when time permits, this can be confusing without live examples :)

    anyone else having a problem with this?

  17. schasoli
    Member
    Posted 2 years ago #

    a similar one.
    Are current events past events? Yes

    But if I use the widget to show only future events, running events are still displayed.
    example:
    event Friday 20:00-22:00 h behaves as a future event till Saturday 00:00 h

  18. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    will try that out and see.

  19. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    this works as expected for me. creating an event that starts before and ends after today will disappear/appear when i turn set it to yes/no

    bear in mind that your blog may have a different timezone than you, meaning an event may end/start before your local time. this trips a lot of ppl up.

  20. schasoli
    Member
    Posted 2 years ago #

    timezone is OK - Scheduling posts works fine.
    If events start yesterday, everything works fine, too

    If events starts and ends today,
    - it apears by today events, even when already finished (not OK)
    - it apears by future events (not OK)

    So "Are current events past events? Yes" is checking the date, but not the start time.

  21. schasoli
    Member
    Posted 2 years ago #

    well, this is a feature-request

    past: by date and time (end of event)
    current: by date and time (show acually running programms)
    future: not started by date and time

  22. Marcus
    NetWebLogic Support
    Plugin Author

    Posted 2 years ago #

    ok, if it's not taking time into account, I'd call that a bug, which will get fixed maybe even today :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic