Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

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) smile

Thanks in advance.

deejayone
Beginner Modder
ranks
useravatar
Offline
1 Posts
Administrator has disabled public posting

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

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

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

tomasoburkaso
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

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 sad

Hope that helps,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3329 Posts
User info in posts
Administrator has disabled public posting

Re: Display module based on City

Hello, it was accurancy problem. Geoip shows my Internet Provider office city, not mine.

Thanks
for fast reaction + accurancy wink

regards
Tomasz

tomasoburkaso
Beginner Modder
ranks
useravatar
Offline
2 Posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1698
Total Polls:
6
Total Posts:
5944
Posts this week:
4
User Info:
 
Total Users:
5543
Newest User:
aj88
Members Online:
1
Guests Online:
147

Online: 
aj88

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked