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.

 

auto detect city or country when visits from specific area

auto detect city or country when visits from specific area

Dear stephen

im looking for a solution for my project.. currently im using metamod..
my website is www.shopingmart.com . basically a classified website so i want when user visit from eg. Newyork USA. so using ip detection automatially redirect to newyork.shopingmart.com  and so on

but this newyork.shpoingmart.com pointing to same root directory as www.shopingmart.com

1- basically i want user from newyork only view ads related to newyork city like olx.com

2- using your one of recipe when redirect user to newyork.shopingmart.com. its not working.. i think because of same index page it become infinite loop because metamod module is at the same page   

can metamod is the solution for me.. or something else

i need your kind suggestion

Sorry for my poor English wink

Best Regards

lordman
Beginner Modder
ranks
useravatar
Offline
10 Posts
User info in posts
Administrator has disabled public posting

Re: auto detect city or country when visits from specific area

Hi Lordman,

using the technique you are using, I can suggest an improvement to prevent the looping. Something like this:

if ($core_genius->check("domain != newyork.shopingmart.com") and $geoip->city == "New York") {
  $app = JFactory::getApplication();
  $app->redirect("http://newyork.shopingmart.com/");
}



In this case it checks to make sure that it only does the redirect on pages that are NOT already on newyork.shopingmart.com.

Make sense?

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: auto detect city or country when visits from specific area

Thanks Stephen

really appreciate your kind help.. and must say metamod is one the powerful module i ever use.. very useful and best module in joomla community
ok
i also saw chameleon and read its features seem very interesting as well.. but i want know like techniques im trying to implement. how much chameleon is useful for me.

i want.. when user redirect to its city or state.. website should display only ads or content related to their city.... i want to implement this for the rest of the world as well.  coding at single index.php i think going to mesh and very inefficient.. so using chameleon is there any option to include different index.php for different countries and display customized layout

Or anything you suggest.

one more question related to metamod and chameleon... can i use regex, javascript and advance db queries in both of modules

my joomla version 2.5.14 and MetaMod v3.14

Cheers

lordman
Beginner Modder
ranks
useravatar
Offline
10 Posts
User info in posts
Administrator has disabled public posting

Re: auto detect city or country when visits from specific area

1 - regex, javascript and advanced db queries:

Mostly yes. The JomGenius calls used above can all use regex. See the JomGenius support pages for details of syntax: http://www.metamodpro.com/jomgenius/about
You can use advanced DB queries in both MetaMod and Chameleon, as both have PHP boxes to write code if you want to.
JS: this can be more of a challenge to integrate depending on what you want to do. If you simply want to be about to output JS as a result of some logic, then both products allow that.

2 - including different index.php: Chameleon can switch template style based on rules like domain or GeoIP, and each template has its own index.php, so that's probably what you are after. Or you could use 1 template (& index.php) with multiple styles, so you set up the parameters for each one in the template style manager, then use Chameleon to switch between them. Global variables you set in Chameleon would also be available in the template, so that would be a way of separating the logic from presentation.

Chameleon can do quite a lot more to customise layout: it can include arbitrary CSS/JS code, switch other plugins on and off, and switch menu items off as a result of any conditions (e.g. domain, GeoIP, whatever).

3 - displaying ads related to city: your initial challenge will be regarding the accuracy (or lack of it) of the GeoCity library. It's not all that accurate. You will need to find a way for people to be able to override the GeoIP detected city. A drop down with other cities in it might be the best way - then Chameleon can pick up that the redirection was done, and use the desired value instead. It does start to get messy at this point though.

As far as restricting ads to the relevant city however: there are several ways you could do it. One is that the template style could name the module positions with a particular city name. So one template style would have a module position "right-newyork". Then you just assign modules to "right-chicago" or "right-newyork" as you manage your modules.

Another method could be to use MetaMod's "module parameter control"  http://www.metamodpro.com/metamod/contr … parameters This is great when a module has a parameter that you want to make dynamic. e.g. a weather module might have a text box parameter called "location" where you enter the city name. With MetaMod, you can programmatically change that, so if you have the location in a variable, you can tell the module to use this variable as the location, instead of the one that was originally set up in the module. This might save you creating hundreds of modules! I've seen it done for weather modules, RSS feeds, news aggregators and other things – it's very powerful.

Another method could be for MetaMod's logic to pick-and-choose between a set of already-set-up modules to display according to location or domain name.

Ultimately, if you are dealing with large numbers of cities (more than 10-20) you're going to need a good way to set this up or it's going to become unmanageable. e.g. requiring a database to store configuration, and probably a component to manage this. Chameleon and MetaMod will happily read a database to get the config info (just 2 lines of PHP to read the db). But you're still dealing with a swiss-army-knife approach rather than a fully integrated solution.

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: auto detect city or country when visits from specific area

Thanks for your kind help and giving precious time. thats really help

im going to consider ur suggestions one by one. again thanks a lot

Best Regards

lordman
Beginner Modder
ranks
useravatar
Offline
10 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:
10789
Newest User:
parus6
Members Online:
1
Guests Online:
313

Online: 
parus6

Forum Legend:

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