Dynamically set a default location for event lists?

Home Forums Calendar Products Events Calendar PRO Dynamically set a default location for event lists?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1073968
    mrtcereal
    Participant

    Hello, I’m trying to figure out how to dynamically set a default location for event views. For instance, if I have a “city” variable, is there a spot in the template files to plug that in and have the events page show events in that city, as opposed to all events?

    I’m comfortable working in PHP, I would just love some help pointing me in the right direction in the templates. Thanks!

    #1074155
    Brook
    Participant

    Howdy Mrtcereal,

    Great question. That’s totally possible to do. Depending on your needs it might not event require PHP.

    When you type something into the Near/Location box it then forwards you to a URL like this:

    /events/?tribe-bar-geoloc-lat=53.5510846&tribe-bar-geoloc-lng=9.99368179999999&tribe-bar-geoloc=hamburg%2C+germany

    As you can see it splits up into three parts. The first two parts are the latitude and longitude of the address you’ve searched for, and the final part is the text that gets prefilled into the Near/Location box.

    If you want to “set a default location” this could be as simple as changing the link to your calendar from /events/ to a URL like the above.

    However, if Map view isn’t your default, or if you want to dynamically set the location, say based on the user’s IP, then PHP is necessary. The easiest and best way would just be to use PHP redirects. If somebody hits the default map view, redirect them to a URL like the one above containing the location of the place you want. The main thing you need to fill in for it to work is the lat/lng. You might need to use a geocoding service like Google’s to obtain that if you are filling it in dynamically.

    Does that all make sense? Will that work for you? Please let me know.

    Cheers!

    – Brook

    #1074580
    mrtcereal
    Participant

    Hi Brook,

    Thanks for the help. I want to do this dynamically, so I’ll look into the geocoding. Just to be clear, the link will work with just the lat and long, correct? I don’t have to set the city?

    Thanks,
    Ted

    #1074750
    Brook
    Participant

    You are correct. The city is only used to fill in the <input> field. It might be nice to fill it in if you wanted to, but I do not see why it would be necessary.

    Let us know how it goes, and if we can assist with our API any.

    Cheers!

    – Brook

    #1084861
    Support Droid
    Keymaster

    This topic has not been active for quite some time and will now be closed.

    If you still need assistance please simply open a new topic (linking to this one if necessary)
    and one of the team will be only too happy to help.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Dynamically set a default location for event lists?’ is closed to new replies.