primitivesocial / ip-country
Get's location information based on user's IP
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 4
Forks: 0
Open Issues: 0
Type:craft-plugin
Requires
- craftcms/cms: ^3.0.0-RC1
This package is auto-updated.
Last update: 2024-11-12 12:36:28 UTC
README
Get's location information based on user's IP
Requirements
This plugin requires Craft CMS 3.0.0-beta.23 or later.
Installation
To install the plugin, follow these instructions.
-
Open your terminal and go to your Craft project:
cd /path/to/project
-
Then tell Composer to load the plugin:
composer require PrimitiveSocial/ip-country
-
In the Control Panel, go to Settings → Plugins and click the “Install” button for IP Country.
IP Country Overview
This get's the user's location data based on their IP address for use in Twig templates.
Configuring IP Country
No need! Comes ready to go out of the box.
For testing locally, you will need to test at a remote server. Running this locally will return your IP address (127.0.0.1), which will not give any data.
A simple way to get around this is to test via Ngrok;
Using IP Country
This sets the IP variable
{% set ip = craft.ipcountry.get %}
Then, you can check to see if the person is in North America
{% if ip and ip.continent_code == 'NA' %}
<p>What up North America!</p>
{% endif %}
Check the city
{% if ip and ip.city == 'Lubbock' %}
<p>Lubbock is the best</p>
{% endif %}
Check the state
{% if ip and ip.state == 'Texas' %}
<p>Texas is awesome!</p>
{% endif %}
Check the country
{% if ip and ip.country == 'Canada' %}
<p>Hooray for Canada!</p>
{% endif %}
IP Country Roadmap
Some things to do, and ideas for potential features:
- Release it
Brought to you by Primitive Social