Skip to content
This repository has been archived by the owner. It is now read-only.
No description, website, or topics provided.
PHP HTML
Branch: master
Clone or download
Latest commit 1970397 Jul 4, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
geo-examples
geo Added IP anonymizer and removed deprecated service (telize.com) Aug 30, 2017
CHANGELOG.md Added IP anonymizer and removed deprecated service (telize.com) Aug 30, 2017
readme.md Deprecated Jul 5, 2019

readme.md

No longer maintained. Will not be upgraded for Craft 3.

Craft 3 alternatives include:

Geo Plugin for Craft CMS

A simple plugin to get information about your users location.

Put the geo folder in your craft plugins folder.

{#
 # The following will cache the users location from their IP, so subsequent
 # api calls are not made, but just looked up in the cache:
 #}
{% set data = craft.geo.info(true) %}

{# which is the same as: #}
{% set data = craft.geo.info() %}

{# An Api call is made on every page view: #}
{% set data = craft.geo.info(false) %}

{# You can then access the data like this: #}
{{ data.country_code }}

Variables available in craft twig templates:

location: {{ craft.geo.info.country_name }}
ip: {{ craft.geo.info.ip }}
country_code: {{ craft.geo.info.country_code }}
country_name: {{ craft.geo.info.country_name }}
region_code: {{ craft.geo.info.region_code }}
region_name: {{ craft.geo.info.region_name }}
city: {{ craft.geo.info.city }}
zipcode: {{ craft.geo.info.zipcode }}
latitude: {{ craft.geo.info.latitude }}
longitude: {{ craft.geo.info.longitude }}
metro_code: {{ craft.geo.info.metro_code }}
areacode: {{ craft.geo.info.areacode }}
cached: {{ craft.geo.info.cached }}

You are limited to 10,000 requests an hour for this plugin. It caches a single IP address for 12 hours by default. You can config this with a config file as explained below.

If you are in Crafts devMode or visiting the site from the server itself then a default IP adress will be used. This setting is configurable by creating a geo.php file in your craft/config folder. An example of this file is found in the geo-examples folder.

TODO

  • Add additional API endpoints for API redundancy.
  • Modularize enpoints so you can add your own endpoint plugins.

Licence

MIT.

Pull requests welcome.

You can’t perform that action at this time.