Home › Forums › Calendar Products › Events Calendar PRO › Dynamically set a default location for event lists?
- This topic has 4 replies, 3 voices, and was last updated 10 years, 2 months ago by
Support Droid.
-
AuthorPosts
-
February 16, 2016 at 12:42 pm #1073968
mrtcereal
ParticipantHello, 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!
February 16, 2016 at 10:27 pm #1074155Brook
ParticipantHowdy 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+germanyAs 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
February 17, 2016 at 10:34 am #1074580mrtcereal
ParticipantHi 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,
TedFebruary 17, 2016 at 8:00 pm #1074750Brook
ParticipantYou 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
March 3, 2016 at 8:35 am #1084861Support Droid
KeymasterThis 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. -
AuthorPosts
- The topic ‘Dynamically set a default location for event lists?’ is closed to new replies.
