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.

 

GeoLite City - help setup script

GeoLite City - help setup script

Hi, I would like to setup redirection to another template or url based on visitors UK City/Region. I am a bit confused how to do this. Do I need to write php code in details php or can I enter this info in quick  rules?

Could you clarify what these functions do?

Joomla frontend language
browsers preferred language
most preferred language from supplied list

anjo
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

Re: GeoLite City - help setup script

Hi Anjo,

The language options aren't going to help you with region selection. There's help text available if you hover over any of these options on the form, and further help in the documentation: http://www.metamodpro.com/chameleon/documentation

To do things based on city/region, you need to code this with some basic PHP.

Of course, first you need to ensure that you have the GeoLiteCity database downloaded (on the configuration page), then enabled in the rule that you're using.

Then in the PHP you can refer to the $geoip variable that contains all the information available to you:

$geoip->country_code   (GB for the United Kingdom)
$geoip->region  (2-letter region code, see all the GB codes on http://www.maxmind.com/app/fips10_4 )
$geoip->city  (full city name, case sensitive, e.g. London)

So you could do something like this:

if ($geoip->country_code == "GB" and $geoip->city == "York") return true;
// then the SUCCEED action will be run for this rule if the user in in York, UK.
// you can put your template changes / redirects in the SUCCEED action.


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
3313 Posts
User info in posts
Administrator has disabled public posting

Re: GeoLite City - help setup script

Hi Stephen,

Thanks for the explanation and code, it is working well for my location. I'll test other locations when possible.

I realise now that I was having problems getting it to work because I wasn't calling the country code. I was just using - if ( $geoip->region == "York" ) return true;

Thanks for the support and a superb component
Regards
Anjo

anjo
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

Re: GeoLite City - help setup script

Hi Stephen,

I am having a problem with this setup.  It works great in the first instance to redirect visitors to the right city area of the website. However, I then need to allow visitors to navigate to other cities within the website by using menu links.

The problem is that the rule keeps picking up visitors location and forcing them to the same city area. Is it possible remove Location variable once visitors are navigating within the website?

Regards
Anjo

anjo
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

Re: GeoLite City - help setup script

Sure, you could base this on a session variable. So as they are redirected, a session variable is set. If that session variable is detected again next time, then the redirect will be bypassed.

So try this:

- Edit your current rule. In the SUCCEED action, choose "set session variable A".
- Create a new rule. In this rule, in the Quick Rules section, select "Cookie/Session Variable: Session Variable A"
- In the SUCCEED action of the new rule, ensure that "stop processing" is chosen.
- Back in the Rule Chain Manager, reorder the rules so that the session varaible check happens BEFORE your other rule.

Once that is set up, then you should find that the redirection only happens ONCE per session. After that, the session variable is set, and the redirection rule only happens ONCE per session.

Cheers,
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
3313 Posts
User info in posts
Administrator has disabled public posting

Re: GeoLite City - help setup script

Hi, I am trying to find out why the this code no longer works after doing a Geoip update.
if ($geoip->country_code == "GB" and $geoip->city == "Sunderland" || $geoip->city == "Gateshead") return true;

It works with my old Geoip database from 2012 but fails with recent update 2014 which I think is Geoip2. I'm using latest version of Chameleon 2.41

Thanks
Anjo

anjo
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

Re: GeoLite City - help setup script

Hi Anjo,

yes, unfortunately the newer GeoIP2 databases are incompatible with the older version that MetaMod is based around. There will be an update to MetaMod at some stage to take account of the new format.

Can you just confirm the URL that you used to get the latest database? I want to compare that to the one I've been recommending on the site to see if the existing GeoIP legacy databases are still available. If not, I'm going to need to do some rapid development!

Thanks,
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
3313 Posts
User info in posts
Administrator has disabled public posting

Re: GeoLite City - help setup script

Hi Stephen,
I clicked on the update link in Chameleon Config urls are:

GeoIP.dat.gz can also be obtained from http://geolite.maxmind.com/download/geo … oIP.dat.gz

GeoLiteCity.dat.gz can also be obtained from http://geolite.maxmind.com/download/geo … ity.dat.gz

Thanks
Anjo

anjo
Beginner Modder
ranks
useravatar
Offline
14 Posts
Administrator has disabled public posting

Re: GeoLite City - help setup script

I originally thought that MaxMind had changed the format of the databases without changing the URL, but this is NOT the case. The original GeoIP (legacy) free databases are still available at the previous locations.

See http://dev.maxmind.com/geoip/legacy/geolite/ for the entire list of free databases and download locations.

In my testing, MetaMod and Chameleon are still working correctly with respect to compatibility with the databases found at these locations:

http://geolite.maxmind.com/download/geo … oIP.dat.gz
http://geolite.maxmind.com/download/geo … ity.dat.gz

Nevertheless I am now working on full GeoIP2 compatibility. Stay tuned.

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
3313 Posts
User info in posts
Administrator has disabled public posting

Re: GeoLite City - help setup script

So Anjo, it's possible that the download of the GeoLite database got corrupted. Try downloading it again, and also make sure that in your Chameleon rule you have told it which one you're using.

Cheers,
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
3313 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5913
Dormant:
User Info:
 
Total Users:
10772
Newest User:
alton29318
Members Online:
0
Guests Online:
136

Online: 
There are no members online

Forum Legend:

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