Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.



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


MetaMod / MetaMod Pro

MetaMod / MetaMod Pro


Firstly, this is a very clever Joomla product. If possible, I would like to be able to display ads based on the users location.

If a user is visiting the website and lives in Queensland I want to display ads specific to Queensland. Or, if the user lives in New South Wales, I want to display ads specific to New South Wales.

As I am not a PHP programmer, I want to know if a PHP script could do the following:

1: Detect the Country, State and City of the website visitor.

2: Then, based on that information, display ads that are specific to that location.

I would probably store ads in a folder structure such as, Country - State - City. In each folder there would be ads from different advertisers.

So the next part of the PHP script would need to load an ad - into a selectable module position on the website - based on the location of the user.

I may not have included everything that would be required to serve ads like this. Hopefully, you understand what I want to achieve.

Would such a script be possible.

Kind regards,


Beginner Modder
2 Posts
Administrator has disabled public posting

Re: MetaMod / MetaMod Pro

I'm hoping to do something similar.  My thought was to create an HTML module containing a banner for each ad. Still trying to get my head around Metamod Pro so looking forward to a post from a more experienced user.

Beginner Modder
1 Posts
Administrator has disabled public posting

Re: MetaMod / MetaMod Pro

Hi guys,

first of all, sorry for the delay in replying. I usually respond within 24-48 hours but this week has been a super busy one.

Robin - the first hurdle for you is to make sure that the GeoLiteCity database that MetaMod can use, actually contains accurate and complete-enough city/state information for Australia.

http://www.maxmind.com/app/geolite_city_accuracy suggests that it gets it right (within 25 miles of true location) just 59% of the time for Australia, gets it WRONG 39% of the time, and can't tell at all 2% of the time. That's not great, but may be good enough for your purposes depending on what they are.

If you want to pay for their more complete database, GeoIPCity, http://www.maxmind.com/app/city_accuracy, then you get 62% + 33% + 5% which is just a bit better.

I'd say, try to get some IP addresses from friends/contacts around Australia, in a few different cities and states, and plug them into the GeoLiteCity demo web site and see what info you get: http://www.maxmind.com/app/lookup_city?type=geolite You'll soon get a feel for how accurate this is.

If you're happy enough with the accuracy, then you can start to look at how to structure an ads system.

Option 1 - just construct the HTML for the ad directly inside MetaMod
Option 2 - set up all your ads as modules in their own right, then use the MetaMod to select which module ID you want to include.

Both have pros and cons. Option 2 is cleaner but starts to get a bit unmanageable as you increase the number of ads available -- you end up having to create each new module, then go into MetaMod to add the new module ID to the PHP recipe.

Option 1 would be better if you already know a bit of PHP and are good with HTML. A simple recipe might go like this:

if ($geoip->city == 'Sydney') {
  $image = "images/au/sydney/ad1.jpg";
  $link = "http://www.example.com/landingpage/product1.html";
  echo '<a href="' . $link . '"><img src='" . $image . '" /></a>';

Now, there are all kinds of ways to improve that -- e.g. maintaining the list of images and links in the database or even in a flat file on the filesystem; making random selections based on a number of options available, and much more.

An example of option 2 would be:
- create a bunch of modules, each with an ad in it
- PHP as follows:

if ($geoip->city == 'Sydney') {
  return XXX; // replace XXX with the module id of the "sydney" ad
if ($geoip->city == 'Melbourne') {
  return YYY; // replace YYY with the module id of the "melbourne" ad

Hope that gets you started,

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

3328 Posts
User info in posts
Administrator has disabled public posting

Re: MetaMod / MetaMod Pro

Hello Stephen,

I appreciate your suggestions - will see what I can do based on your recipe examples.

May need to come back to you later for some more help.


Kind regards,

Beginner Modder
2 Posts
Administrator has disabled public posting

Board Info

Board Stats:
Total Topics:
Total Polls:
Total Posts:
Posts this week:
User Info:
Total Users:
Newest User:
Members Online:
Guests Online:

There are no members online

Forum Legend:

 New Sticky