Chosing a specifc date returns results FROM the date and not ON the date

Home Forums Calendar Products Events Calendar PRO Chosing a specifc date returns results FROM the date and not ON the date

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #750933
    efromdc
    Participant

    I need to select a date on the front end that displays events ON the date in question. The plugin returns events FROM the date in question.

    I just read this and disagree with the notion that this is a “feature” -> https://tri.be/support/forums/topic/selecting-a-day-returns-other-days-besides-the-one-i-pick/

    I guess it depends on one’s perspective…but I dont agree with the logic of the Tri.be representatives explanation of: “What you are describing appears to be a feature of our plugin. In all list views, namely List, Map, Photo, it shows event from that day forward.”

    The person that authored that reply was very careful in his wording: “So if you search FROM June 21st.” Which is NOT what the thread author asked for. He stated “here is the result for a search of events ON June 12 2014: http://brasileirinho.com/pt/events/?action=tribe_photo&tribe_paged=1&tribe_event_display=photo&tribe-bar-date=2014-06-12”

    Not “FROM” June 12th forward…”ON” June 12th.

    I have the exact issue, but its compounded by the notion that I have 10 sites representing Washington DC and its Suburbs. I’m trying to find events ON Halloween, Oct 31st, and its giving me events FROM October 31st. Which is incorrect:
    http://socialalerts.com/washingtondc/events/photo/?action=tribe_photo&tribe_paged=1&tribe_event_display=photo&tribe-bar-date=2014-10-31

    OK (and sorry to be long winded…lol) -> Here are my question(s):

    1. How do I specify “events that start ON October 31” – Not events FROM October 31st and forward…I mean STRICTLY that start ON October 31st?

    2 (not really a question). For the record, I have a work around but the work around isn’t viable: Please do NOT reply with my workaround of “go into the backend, filter events as startdate = oct 31st, crate a “2014-10-31” category, mark those events with the 2014-10-31 category and then make a link called /events/2014-10-31 🙂 While this workaround would work as a stopgap, the solution isn’t viable because I’d have to make 365 categories if I want the user to be able to see events on any specific day of the year. In addition, I have to make 10 2014-10-31 categories, one for each site (um…no) and as for searching on each day of the year? 10 sites based on suburbs of Washington DC, 365 days so I’d have to 3650 categories…um…no. Again

    🙂 🙂 🙂

    3. Why are you able to select dates that START as 2014-10-31 in the admin/backend at /wp-admin/edit.php?post_type=tribe_events via the filter that do NOT include dates that start afterwards…but NOT in the front end date picker? Seems to be a direct contradiction to what the tribe representative in the other thread stated…

    4. I see this in the original thread also: “If you would like to change this functionality to only show event from the date searched…you would simply hook into ‘tribe_events_pre_get_posts’, check if the URL action var is tribe_photo, or tribe_upcoming or tribe_map, and if the tribe-bar-date parameter is set. If so, limit the query to today by adding a condition for the post meta _EventStartDate that check to see if the event is lesser than tomorrow.” – This is way over my head and also isnt correct because it addresses “TODAY” not “the date selected,” in MY case, 2014-10-31

    4a. Can I get a snippet that limits the returned events as described above but ONLY for the date selected?

    4b. In which file should I add the snippet?

    FYI – Im using version 3.5.1 – I had asked a question previously about database field name changes when upgrading and never got an answer…so I can’t upgrade until I hear back concerning that. (If you decide to research any database field name changes please NO NOT delay the answers to 1-4. Just reply when you get an answer. And THANK YOU!

    – efromdc

    #753078
    Barry
    Member

    Hi efromdc,

    Some great questions there!

    1. How do I specify “events that start ON October 31″ – Not events FROM October 31st and forward…I mean STRICTLY that start ON October 31st?

    We provide day view for broadly this purpose.

    It doesn’t completely meet your criteria – because it will also show ongoing events (such as an event that started the day before and finishes on the following day) – but without making any modifications that is as close as you are going to get to the behaviour you are seeking.

    If you want to bring this across to other views such as map or photo view then the steps outlined by Brook in the previous thread you referenced are a great starting point – though some additional work is probably required on top.

    While this workaround would work as a stopgap, the solution isn’t viable because I’d have to make 365 categories

    I’d agree that wouldn’t serve as much more than a stopgap, props for creativity though 🙂

    3. Why are you able to select dates that START as 2014-10-31 in the admin/backend at /wp-admin/edit.php?post_type=tribe_events via the filter that do NOT include dates that start afterwards…but NOT in the front end date picker? Seems to be a direct contradiction to what the tribe representative in the other thread stated…

    I’m not quite sure why this contradicts Brook’s remarks.

    These are two different systems: we use Advanced Posts Manager in the admin environment with a goal of delivering a better toolset and experience for site administrators. The front end experience on the other hand is tuned to the needs of regular visitors.

    4a. Can I get a snippet that limits the returned events as described above but ONLY for the date selected?

    I can certainly give you a starting point, which is as follows:

    add_action( 'tribe_events_pre_get_posts', 'modify_date_based_filtering' );
    
    function modify_date_based_filtering( $query ) {
    	// In this example we're interested in photo view - but you can extend this
    	// condition to cover additional views where it makes sense to do so
    	if ( ! $query->tribe_is_photo ) return;
    
    	// Do not interfere if a specific start date was not specified
    	if ( empty( $query->get( 'start_date' ) ) ) return;
    
    	// Set the end date to match the start date
    	$end_of_day = TribeDateUtils::endOfDay( $query->get( 'start_date' ) );
    	$query->set( 'end_date', $end_of_day );
    }

    It’s a little more complicated than that however because of the dynamic nature of these views.

    The above should work, within photo view, but only if someone navigates directly to the URL for a specific date. When using the datepicker under ordinary conditions it probably won’t work as expected because of the way our Javascript handles pagination and updates.

    With that in mind, further work would be required to bring this to fruition 🙂

    4b. In which file should I add the snippet?

    Your theme’s functions.php place is often a suitable venue for code like this, though setting it up in a plugin of its own may be better.

    Bearing in mind the limitation I described for your question 4a, though, this is a little more involved than just adding that code alone (though hopefully it gives you a decent starting point).

    FYI – Im using version 3.5.1 – I had asked a question previously about database field name changes when upgrading and never got an answer…so I can’t upgrade until I hear back concerning that. (If you decide to research any database field name changes please NO NOT delay the answers to 1-4. Just reply when you get an answer.

    Do you mean your second question from this thread? It looks like Casey provided an answer if so – but if you need further details please create a new thread and one of the team will be only too happy to help.

    Thanks again!

    #757312
    efromdc
    Participant

    Trying this out now…

    #758768
    Barry
    Member

    Great!

    #794301
    Barry
    Member

    Hi! It’s been a while so I’m going to go ahead and close this thread. If we can help with anything else, though, please don’t hesitate to create new threads as needed. Thanks!

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Chosing a specifc date returns results FROM the date and not ON the date’ is closed to new replies.