primitivesocial/ip-country

根据用户的IP获取位置信息

安装: 0

依赖: 0

建议者: 0

安全: 0

星星: 1

关注者: 4

分支: 0

开放问题: 0

类型:craft-plugin

dev-master 2019-02-12 00:10 UTC

This package is auto-updated.

Last update: 2024-09-12 12:05:55 UTC


README

根据用户的IP获取位置信息

Screenshot

要求

此插件需要Craft CMS 3.0.0-beta.23或更高版本。

安装

要安装插件,请按照以下说明操作。

  1. 打开您的终端并进入Craft项目

     cd /path/to/project
    
  2. 然后告诉Composer加载插件

     composer require PrimitiveSocial/ip-country
    
  3. 在控制面板中,转到设置→插件,并点击IP Country的“安装”按钮。

IP Country概览

此插件根据用户的IP地址获取用户的位置数据,用于在Twig模板中使用。

配置IP Country

无需配置!直接使用即可。

对于本地测试,您需要在远程服务器上进行测试。本地运行此插件将返回您的IP地址(127.0.0.1),这不会提供任何数据。

解决此问题的简单方法是使用Ngrok进行测试;

使用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路线图

一些要完成的事情和潜在功能的想法

  • 发布

Primitive Social提供