Skip to content
This repository has been archived by the owner on Jul 5, 2019. It is now read-only.

lukeholder/craft-geo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published