IP Dependent Content Display

Hello guys,

Please I have this 4 set of files to display on my pages based on country.

Help me with this codes,


XXXXXXXXXXXXXXXXXXXXXXXXXX

 <script language="JavaScript" src="http://j.maxmind.com/app/country.js"></script>
<script language="JavaScript">
var country=geoip_country_code();
if(country == "US"){
    document.getElement.href = '/indicators/us.html';
}
if(country == "UK"){
    document.getElement.href = '/indicators/uk.html';
}
if(country == "CA"){
    document.getElement.href = '/indicators/ca.html';
}
else{
    document.getElement.href = '/indicators/soon.html';
}
</script>

XXXXXXXXXXXXXXXXXXXXXXXXX


 I cant get it to work for me. Or maybe it should be in PHP

Am placing it in the HTML block.

Am a newbie please

Quote · 21 Oct 2015

Is installing GeoIP on your server an option for you?  It would be easier to work with than an API, and when using a server-side language instead of html, you'll have a lot more versatility.

 

Then php code looks like this:

if ($_SERVER['GEOIP_COUNTRY_CODE'] = "US" ){
echo "Hello United States";
} elseif ($_SERVER['GEOIP_COUNTRY_CODE'] = "UK" ){
echo "Hello United Kingdom";
} elseif ($_SERVER['GEOIP_COUNTRY_CODE'] = "CA" ){
echo "Hello Canada";
}


 

My opinions expressed on this site, in no way represent those of Boonex or Boonex employees.
Quote · 21 Oct 2015

 Hello HL,

 I have a set of different information for different countries as seen in the screen shot made possible by simply embedding the links in the HTML BLOCK.

However, I tried the other country-specific info to be displays using the following PHP code in the HTML BLOCK

<?php
if ($_SERVER['GEOIP_COUNTRY_CODE'] = "NG" ){
    echo "/indicators/ng.html";
} elseif ($_SERVER['GEOIP_COUNTRY_CODE'] = "UK" ){
    echo "/indicators/uk.html"";
} elseif ($_SERVER['GEOIP_COUNTRY_CODE'] = "CA" ){
    echo "/indicators/ca.html";
}

?>

 My Observation
 It gets commented out automatically when saved and displays nothing.
 HOW BEST can I achieve this goal?
 Is this (echo "/indicators/ng.html";) even correct?

 Please help

Corel034.jpg · 43.9K · 273 views
Quote · 22 Oct 2015

Thanks for ever responding to me

Quote · 22 Oct 2015

You didn't answer my question

My opinions expressed on this site, in no way represent those of Boonex or Boonex employees.
Quote · 22 Oct 2015

HL,

 

I didn't answer because I am not knowledgeable enough in this to know what is best and i thought you were trying to tell me the best option notwithstanding what i had in mind.

So I wont mind installing GeoIP or anything else, my priority is to achieve result and reason why i tried to explain my desired goal

Thanks

Quote · 22 Oct 2015

 

So I wont mind installing GeoIP or anything else,

 Then I suggest you first install GeoIP and GeoIP Apache module on your server, or get your hosting provider to do so.

 

http://dev.maxmind.com/geoip/legacy/mod_geoip2/

My opinions expressed on this site, in no way represent those of Boonex or Boonex employees.
Quote · 22 Oct 2015

Hi HT,

I am back.

I contacted my host and they told me they cannot install GeoIP2 on Shared server and that leaves me with a PLAN B,


I have installed the Deano Mod to add PHP Block to my site, I inserted this

include 'indicators/ng.html'; and it worked fine.


PLAN B

I want this templates displayed based on the Dolphin Country Value for the profile in view just the way a set of info is displayed based on UserID.


For example,

Assume I have your profile on my site, if I select your profile for viewing and your profile has US in the database as your country of residence, then a template file is included on the profile_info.php page


However, I do not know the string or variable for Country and the correct php code format.

So please correct this following code for me to insert in the PHP Block


if ($_UserCOUNTRY['COUNTRY'] = 'US'  ){

                include 'indicators/us.html';

}

elseif ($_UserCOUNTRY['COUNTRY'] = UK' ){

    include 'indicators/uk.html';

}

elseif ($_UserCOUNTRY['COUNTRY'] = "NG" ){

    include 'indicators/ng.html';

}

else {

    include 'indicators/soon.html';

}

 

Thanks in advance

 

Quote · 29 Oct 2015
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.