(how to) sort events by distance?

Home Forums Calendar Products Events Calendar PRO (how to) sort events by distance?

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #1181794
    Francesco
    Participant

    Hello,
    is there a way to sort the events by distance?
    I mean: after performing a search, an user would normally expects to see the events displayed by distance, with the closest event listed as first.

    If there is no “offical” way to do it, can you tell me which file manage that loop?

    Thanks in advance,
    f

    #1181795
    Francesco
    Participant

    BTW: I see that distances are not accurate: there’s always some hundred meters of difference between the real distance and what is actually displayed… It seems that the system calculates the route on foot but it is shorter of 300mt or stuff like that. Any idea?

    • This reply was modified 7 years, 6 months ago by Francesco.
    #1182223
    Cliff
    Member

    Francesco, this is a neat idea.

    You could request this as a new feature (or maybe search to see if the idea was already posted by someone else) at our plugins’ UserVoice page.

    This allows others who are interested in that feature to easily voice their support. We frequently review suggestions there to find out which ones are popular, then we implement as many of them as we can.

    If you post it / find it, feel free to link to it from here in case anyone comes across this forum thread in the future.

    ===

    As far as a file to look into, I’d suggest starting out by referencing /wp-content/plugins/events-calendar-pro/src/Tribe/Geo_Loc.php

    tribe_get_distance_with_unit() is used in that file but defined in /wp-content/plugins/events-calendar-pro/src/functions/template-tags/general.php

    Please let me know if you have any follow-up questions on this topic.

    #1182469
    Francesco
    Participant

    Thanks for answering.
    I guess that I should find where the results are displayed in loop.
    If they are stored into an array maybe they can be reorderd.
    Or maybe this is just a silly idea.
    Anyway, if you can tell me more I will appreciate!

    I’ve posted my suggestion in the provided link.
    But I would venture to say that if I can perform a search by address I should have the nearest place as first result… and then the other one placed depending on the distance…

    f

    #1182825
    Cliff
    Member

    That Geo_Loc.php file has setup_geoloc_in_query() hooked into tribe_events_pre_get_posts.

    That might be the function to look into. However, it looks like that function only gets the Venues within a geofence area without any sorting.

    There’s also add_event_distance() that gets output in the Photo View: /wp-content/plugins/events-calendar-pro/src/views/pro/photo/single-event.php

    You might be able to leverage something like these (and other functions you may find) to hook into tribe_events_pre_get_posts (possibly with a different priority).

    If you do figure this out, feel free to share your code for others to benefit from — or for us to possibly implement into the core code of PRO in a future version.

    Again, you could/should submit the idea on UserVoice.

    #1183061
    Francesco
    Participant

    Thank you for your help.
    I’ll try something starting from your hints.
    And, of course, I’ll share my results if they will work!

    Yesterday I’ve posted the request in user voice as suggested
    https://tribe.uservoice.com/forums/195723-feature-ideas/suggestions/16804615-sort-events-by-distance

    Regards
    f

    #1183063
    Francesco
    Participant

    Here’s my post to be voted if someone should find this feature useful:

    https://tribe.uservoice.com/forums/195723-feature-ideas/suggestions/16804615-sort-events-by-distance

    #1183300
    Cliff
    Member

    Thanks for sharing that link here.

    I’ll leave this thread open for a time in case you have code to share, but please note that threads get Closed automatically after a couple weeks of inactivity. If it does get Closed, feel free to open a new thread, adding your current problem description and also linking back to this thread.

    Thank you!

    #1193895
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘(how to) sort events by distance?’ is closed to new replies.