2017 © Pedro Peláez
 

silverstripe-module silverstripe-regionaldata

Provides country and country subdivision datamodels, along with data.

image

burnbright/silverstripe-regionaldata

Provides country and country subdivision datamodels, along with data.

  • Thursday, March 24, 2016
  • by jedateach
  • Repository
  • 1 Watchers
  • 5 Stars
  • 172 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 3 Forks
  • 4 Open issues
  • 2 Versions
  • 2 % Grown

The README.md

Regional Data Module

Provides reusable models, data, and fields for hierarichal geographical region classification of countries, and their subdivisons. The module should help to close the gap between known data, and arbitrary (possibly invalid) data entered by visitors., (*1)

A strong focus has been put on following the ISO 3166 standard., (*2)

This module is not intended to replace zend_locale., (*3)

Installation

  • Unzip to your silverstripe root / regionaldata.
  • Visit yoursite.tld/dev/tasks/LoadRegionalData

You should now be able to see countries and subdivisions in yoursite.tld/admin/regions, (*4)

Possible Uses

  • Auto-completion country and state fields
  • Drop-down fields for entering valid data
  • Connect with other models for regionalisation
  • Addressing systems

Javascript Field Updater

Require the following script to templates / forms which have Country and State fields: regionaldata/javascript/updater.jquery.js, (*5)

If you are using the shop module, a good place to include this is in an extension of Address:, (*6)

function updateFormFields(FieldList $fields, $nameprefix = ""){
    Requirements::javascript('regionaldata/javascript/updater.jquery.js');
}

Provided Data Set

2nd level subdivisons have different names, eg: area, district, parish, county., (*7)

Most data has been sourced from commondatahub.com., (*8)

In the provided dataset, some countries have multiple types of subregion. There aer about 100 different subregions all toegether. In one case (United Kingdom), 11 types of sub region are present. This results in a very confusing 'Region/State' dropdown.You will probably not want to make every type available to users, so some cleanup will be needed., (*9)

This query will identify every type of sub region:, (*10)

    SELECT DISTINCT `Type`
    FROM `CountrySubdivison` WHERE 1
    ORDER BY `Type`

Running this query will show the countries with multiple subregion types:, (*11)

    SELECT *, COUNT(DISTINCT `Type`) as `Types`
    FROM `CountrySubdivison`
    GROUP BY `CountryID`
    HAVING `Types` > 1
    ORDER BY `Types` DESC

Future TODO / Ideas

  • Write a SQL query to clean up data set
  • Store address formats. Some countries don't require all address fields, others do.
  • Translation of names
  • 3rd-level post/zip code storage model

The Versions

24/03 2016

dev-master

9999999-dev

Provides country and country subdivision datamodels, along with data.

  Sources   Download

BSD-2-Clause

The Requires

 

address silverstripe data countries state region province

16/07 2014

0.2.1

0.2.1.0

Provides country and country subdivision datamodels, along with data.

  Sources   Download

The Requires

 

address silverstripe data countries state region province