Is there a way to get the IP to Nation Module to put the nation value into a string? Such that it can used to define products, services and/or content to be displayed?
Maybe there an add-on for this? Anybody?
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
July 29, 2010 6:22pm
Subscribe [3]#1 / Jul 29, 2010 6:22pm
Is there a way to get the IP to Nation Module to put the nation value into a string? Such that it can used to define products, services and/or content to be displayed?
Maybe there an add-on for this? Anybody?
#2 / Jul 31, 2010 2:02pm
I checked this out and ran into a number of parse issues with built in variables. Here is what works for me:
<?php $ip=$_SERVER['REMOTE_ADDR']; ?>
{exp:query sql="SELECT country as country_code FROM exp_ip2nation WHERE ip < INET_ATON('<?php echo $ip; ?>') LIMIT 1"}
{country_code}
{/exp:query}Install the IP_to_nation module
Grab the IP address via PHP
Use a PHP-based query with the IP address parameter (needs to be processed on INPUT)
Return the country_code.
You should be able to build whatever conditionals you need based on this.
Note: You’ll need to double check on the use of INET_ATON as I’m not sure my example above builds an accurate parameter string.
#3 / Sep 01, 2011 11:21pm
Thank you Mark!
This worked perfectly for me to show country specific content on a home page!
Cheers,
Danielle