Giter Site home page Giter Site logo

processwire-countries's Introduction

WARNING: This repository is no longer maintained ⚠️

This repository will not be updated. The repository will be kept available in read-only mode.

ProcessWire Continents and Countries

Displays countries and continents and their iso codes.

The "value" for each country is the two-letter country code.

As an added bonus, the country names are displayed in the language of the user (sorted by name ASC) if the appropriate translation was added.

Example Frontend

Fieldtype

This module adds a Fieldtype: Select Options Countries.

Field settings:

Example Field Settings

Example

PHP

<?php $countries = $modules->get('ContinentsAndCountries')->findByContinent('eu'); ?>

<select>
  <?php foreach ($countries as $country): ?>
    <option value="<?=$country->code; ?>">
      <?=$country->name; ?>
    </option>
  <?php endforeach; ?>
</select>

Translations

To translate the continents and countries, you must have the ProcessWire Language Support module installed. This is included with ProcessWire, so all you have to do is click to Modules > Language > Language Support > install.

Once you have Language Support installed, you have to add or edit the desired language by going to Setup > Languages > Add New Language. Enter a title and name for the language and save.

Next, you can add the file for the language (have a look at site/modules/ContinentsAndCountries/translations/ if the translation for your language exists) or translate it manually.

Available Methods

  • getContinents()
  • getCountries()
  • getByContinent($continent)
    • $continent has to be one of af, as, eu, na, sa, oc, an
    • (Africa, Asia, Europe, North America, South America, Oceania, Antarctica)
  • findBy($table = 'countries', $select = array(), $options = array())
    • for example: findBy('countries', array('name', 'iso'), array(id => 2))

    • returns:

        array (size=1)
          0 => object(stdClass)[1059]
              public 'name' => string 'Åland-Inseln' (length=13)
              public 'iso' => string 'ALA' (length=3)

processwire-countries's People

Contributors

justb3a avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

daun

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.