MC Country

Developer

Michael Cohen - ProImage

3rd Party (Free)

49 downloads (last 90 days)

Download v1.1.1

EE Version Support

  • ExpressionEngine 2

Compatibility

If an item is crossed out, it might be untested, not applicable or incompatible. Contact the developer to be sure.

  • Updater
  • Multi Site Manager
  • Stand Alone Entry Form
  • Low Variables
  • Content Elements
  • Better Workflow
  • Matrix
  • Grid
  • Webservice
  • Publisher

Requirements

  • jQuery for the Control Panel

Add-On Type(s)

Plugin

Tags

Uses the IP2Nation module to detect and output a visitor's country (the ISO country code) from their IP. Can optionally display content or redirect to a URL if a visitor is from a specified list of countries.

Based on OpenMotive’s Country plugin (see credits).

PLEASE NOTE
This plugin requires the “IP to Nation” module.

Release Notes

     
  • v1.1.1 (2016-02-17) - Fixed documentation specifying `allowed` instead of `allow`
  •  
  • v1.1.0 (2015-06-15) - Added tag pair support
  •  
  • v1.0.1 (2014-09-03) - Original release

FEATURES

This plugin has five main features.

     
  1. OUTPUT COUNTRY CODE

    To output just the two-letter country code, place the following tag in any of your templates:

    {exp:mc_country}

    REQUIRED PARAMETERS

    None.

    OPTIONAL PARAMETERS

    • default = If a visitor’s IP cannot be located, the country code will default to this value.
    • debug = Force a specific two-letter country code. Useful when working locally (IPs won’t resolve to the correct country on your local network).
  2. COUNTRY BASED REDIRECT

    To redirect if user is from a specified country, specify a list of countries and a redirect path.

    {exp:mc_country countries="xx|xx|xx|xx" redirect="/path/to/redirect/to"}
    

    REQUIRED PARAMETERS

    • countries = List each two-letter country code separated by |
    • redirect = The url to redirect to if user is from one of the specified countries.

    OPTIONAL PARAMETERS

    • default = If the IP cannot be located, country code will default to this value. Useful when working locally on your own machine.
    • debug = Force a specific two-letter country code. Useful when working locally (IPs won’t resolve to the correct country on your local network).
  3. COUNTRY SPECIFIC CONTENT

    If you need to display content for visitors from specific countries, simply wrap the content in tags and specify the countries as a parameter.

    {exp:mc_country countries="xx|xx|xx"}
        Content here
    {/exp:mc_country}

    REQUIRED PARAMETERS

    • countries = List each two-letter country code separated by |

    OPTIONAL PARAMETERS

    • debug = Force a specific two-letter country code. Useful when working locally (IPs won’t resolve to the correct country on your local network).
  4. RESTRICTED SUBSET COUNTRY DETECTION

    This feature allows you to restrict which countries visitors are detected from to a specified subset. If a visitor is from one of the allowed countries, it outputs that country. If a visitor is from a country not specified in the subset of allowed countries, it outputs the specified default country. See the examples below for ideas on how to use this feature.

    {exp:mc_country:restrict allow="xx|xx|xx" default="xx"}
    

    REQUIRED PARAMETERS

    • allow = List each two-letter country code separated by |
    • default = If IP cannot be located, country code will default to this value. Note that the default country should typically also be listed among the allowed countries.

    OPTIONAL PARAMETERS

    • debug = Force a specific two-letter country code. Useful when working locally (IPs won’t resolve to correct country on your local network).
  5. COUNTRY DETECTION TAG PAIR

    Using the tag pair can give more flexibility in parsing the results of the country detection. It also gives you access to the country name in addition to the code, and allows you to determine whether the code should be returned as upper- or lowercase.

    {exp:mc_country:pair case="upper"}
    	The country code "{country_code}" belongs to {country_name}
    {/exp:mc_country:pair}
    

    REQUIRED PARAMETERS

    None.

    OPTIONAL PARAMETERS

    • code_case = Return the {country_code} value as uppercase (code_case=“upper” or code_case=“uppercase”) or lowercase (default, can also be specified as code_case=“lower”)
    • debug = Force a specific two-letter country code. Useful when working locally (IPs won’t resolve to correct country on your local network).

    VARIABLES

    • {country_code} = The two-letter country code
    • {country_name} = The English name of the detected country.

EXAMPLES

  • Output two digit country code, defaulting to US:

    {exp:mc_country default="us"}
  • Redirect the user if they are from the US, UK, or Canada:

    {exp:mc_country countries="us|gb|ca" redirect="/english"}
  • You can also redirect to another site completely:

    {exp:mc_country countries="ca" redirect="http://www.google.ca"}
  • Use debug mode to force United States country code:

    {exp:mc_country countries="us|ca|gb" redirect="http://www.google.ca" debug="us"}
  • Show certain content to visitors from the US, Canada, and Mexico:

    {exp:mc_country countries="us|ca|mx"}
        <h2>Hello, North America!</h2>
    {/exp:mc_country}
  • Figure out which branch of an organization to use for a visitor:

    {exp:mc_country:restrict allow="us|ca|uk|jp" default="us"}

    If a visitor is detected as being in Canada, the output would be:

    ca

    If a visitor is detected as being in Germany, which is not in the specified list of allowed countries, the output would default to:

    us
  • Display country name and code using the tag pair:

    {exp:mc_country:pair code_case="upper"}
        The country code for {country_name} is {country_code}
    {/exp:mc_country:pair}

COUNTRY CODES

A list of country codes can be found at:
http://www.iso.org/iso/english_country_names_and_code_elements

CREDITS

This is an EE2 port & enhancement of the OpenMotive Country EE1 plugin.

Due to significant changes in the way data is stored in EE2’s IP database table, I had to copy and adapt two internal functions from EllisLab’s IP2Nation module. No copyright infringement is intended - I simply couldn’t figure out how to make use of the database table otherwise.

Download MC Country

EE Support Downloads Add-On Version Release Date
Not Specified Download 1.1.1 Feb 17, 2016

MC Country Links

This entry was created June 20, 2013, 9:22 am.
This entry was last updated February 17, 2016, 11:27 am.

Disclaimer: Information about ExpressionEngine add-ons is provided as a service to you, the user, and every member of the ExpressionEngine community. devot:ee is not responsible if you hose, mangle, wreck, or otherwise destroy your EE website by installing an add-on that you found out about at this site, regardless of its rating, Favorites status, commercial or free status, or general popularity. Caveat EEmptor!

Returns: devot:ee has a 30-day return policy on all commercial add-ons sold through devot-ee.com. If you need to return an add-on, do not go to the developer or the developer's site, but rather visit our returns page at https://devot-ee.com/returns to initiate your return. If you have questions, email support@devot-ee.com.

2 Reviews:

Anthony Mellor 11.20.14

Anthony Mellor
Rating - {addon_rating_average}

Very useful add-on and good support from the developer

o4 11.21.13

Rating - {addon_rating_average}

Works like a charm. Tested on EE 2.5.5. Thanks!