How to use GeoIP & Context GeoIP module

Using the GeoIP module with Context GeoIP module, it makes it really easy to create a context which has a specific condition to only display a block if your IP location is from a particular country.

Furthermore GeoIP has a powerful API to pull out location information.

In this article I’ll show you how to setup GeoIP and Context GeoIP module.

Getting started

A few modules will need to be downloaded before we start. Download the following modules:

  1. GeoIP
  2. Context GeoIP
  3. Context
  4. Ctools (required by Context)

Once the modules have been downloaded go and enable the GeoIP and Context GeoIP module.

geo_1.png

Configure GeoIP

Once you have enabled GeoIP you’ll have to download the MaxMind database file.

The country binary file can be downloaded from: http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz

Once you have downloaded the file, uncompress the file and copy it into “sites/all/libraries/geoip”. To make sure everything is working to go “admin/settings/geoip” and if you get an error, double check and make sure the binary file is in “sites/all/libraries/geoip”.

geo_2.png

Context Geo IP

If you haven't already done so go and enable the Context Geo IP module. NOTE: Don’t forget to enable Context and Ctools.

geo_3.png

Now go to a context rule and you should see Geo IP in the condition select box.

geo_4.png

And there you have it, now you can create context rules for a specific IP location.

Category: 
Tags: 

Ivan is the founder of Web Wash and spends most of his time consulting and writing about Drupal. He's been working with Drupal for 6 years and has successfully completed several large Drupal projects in Australia.

Connect: Twitter drupal.org LinkedIn App.net