GeoIP country examples
Use MetaMod’s GeoIP facilities to target modules to viewers from different countries/states/cities (accuracy of state and city location varies by country, but country accuracy is very high). You can even combine country rules with date/time rules to target different countries at different times of the day...
Please ensure you install the GeoIP Country or City databases from Maxmind before using these rules, or they will fail!
If you just wish to show modules to visitors from certain countries, it's simpler to use the configuration boxes for doing this (including or excluding certain countries). The power of the MetaMod PHP box comes when you combine the GeoIP rules with other rules.
Any of the following rules can be used independently of the others.
if ($fromCountryId == "US") return 55;
if ($fromCountryId == "GB") return "55,56,57";
if ($fromCountryId == "NL") return array(58,59,73);
if ($fromCountryName == "New Zealand") return 21;
//advert in mornings for US viewers if ($fromCountryId == "US" && MM_TIME > 70000 /* 07:00:00 AM */ && MM_TIME <= 120000 /* 12:00:00 midday */) return 23;
//advert in lunch break for US viewers if ($fromCountryId == "US" && MM_TIME >= 120000 && MM_TIME <= 140000 ) return 24;