Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.
- Index
- » MetaMod
- » MetaMod General Support
- » Display module based on City
Display module based on City
Display module based on City
Hey - great module functionality, thanks!
I have a problem in that I am not a PHP coder or anything, but am seeking to get a recipe for displaying a module for specific cities...
I've managed to get it working for countries, which is great and really easy to do! But the parameters I want now is: if xxx country and xxx city then display xxx module - I assume this is possible, but am limited in my knowledge.
Can someone with a bit more knowledge please help me out with a recipe - I'm sure it's probably really easy, but I am struggling!
(By the way, I've scanned through all the recipes and forum posts and can't find anything on these lines yet, so apologies if I am dupicating a question)
Thanks in advance.
Re: Display module based on City
Hi deejayone,
in order to do this you need to install the GeoCityLite database from MaxMind. It's different to the free country database from them. Then you need to enable that at the top of the MetaMod.
Once that's installed, then you can use some special variables in your rules. They are described near the bottom of this page:
http://www.metamodpro.com/metamod/configuration
... in the PHP section.
e.g. $geoip->city and $geoip->country_code
so then you can do things like:
if ($geoip->country_code == 'FR' and $geoip->city == 'Paris' ) return XXX; /* replace XXX with module id of the module to include */
It's always good to check the country and city name together, as you never know how many other countries have a town or city by the same name...
Hope that helps,
Stephen
Re: Display module based on City
Hello
I have problem with:
if ($geoip->country_code == "PL" and $geoip->city == "Warsaw") return 111; don't work, see nothing
when
if ($geoip->country_code == "PL" ) return 111; works fine, display proper module
GeoIP Check geoip/GeoLiteCity.dat found. GeoIP City/region features enabled.
Joomla 1.5.15
Re: Display module based on City
Hi Tomas,
the GeoLiteCity database is not terribly accurate in some countries of the world. If you are in Warsaw at the moment, then you can test out to see what the database has for your IP address, by putting the following into the PHP box:
echo "Current guest:";
echo "<pre>";
print_r($geoip);
echo "</pre>";
Perhaps there's no city given at all, or perhaps it's showing the wrong one. Everything depends on the accuracy of the MaxMind database.
See http://www.maxmind.com/app/geolite_city_accuracy for accuracy information.
It claims about a 60% accuracy rate for Poland, which is not that high
Hope that helps,
Stephen
- Index
- » MetaMod
- » MetaMod General Support
- » Display module based on City
Board Info
- Board Stats:
- Total Topics:
- 1689
- Total Polls:
- 6
- Total Posts:
- 5942
- Total Posts Today:
- 1
- User Info:
- Total Users:
- 7622
- Newest User:
- boestreecare
- Members Online:
- 2
- Guests Online:
- 130
- Online:
- boestreecare, musser4585
Forum Legend:
Topic
New
Locked
Sticky
Active
New/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky/Active/Locked