Download the PHP package kadegray/statamic-country-and-region-fieldtypes without Composer

On this page you can find all versions of the php package kadegray/statamic-country-and-region-fieldtypes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package statamic-country-and-region-fieldtypes

Statamic Country And Region Fieldtypes

Statamic Country And Region Fieldtypes is an addon that is everything you need to store and display Country and Region on your site.

Features


How to Install

Search 'Country and region' addon in the Tools > Addons section of the Statamic control panel and click install, or run the following command from the root of your project:


How to Use

You will notice that there are three Fieldtypes in this addon, this gives you the most control over how you would like to store country and/or region data.

Country Fieldtype

After adding the Country Fieldtype into your blueprint and editing an entry, the select input will display the names of countries. However, when you save the entry, the fieldtype will store the two-letter country code as the value.

<img src="readme/images/entry_country_empty.png" alt="Empty Country select on an entry" />

<img src="readme/images/entry_country_typeing_can.png" alt="Typing can into Country fieldtype displaying filtered country on an entry" />

<img src="readme/images/entry_country_selected_canada.png" alt="Country fieldtype with Canada selected on an entry" />

If you designate the field handle as "country" you can use the following code in the template to display the name of the country.

If you are using multi-site, the aforementioned code will correctly display the country name in the language associated with the locale of the current site you are visiting.

Region Fieldtype

<img src="readme/images/entry_region_empty.png" alt="Empty Region select on an entry" />

<img src="readme/images/entry_region_typing_br.png" alt="Typing br into Region fieldtype displaying filtered region on an entry" />

<img src="readme/images/entry_region_selected_bc.png" alt="Region fieldtype with British Columbia selected on an entry" />

The Region Fieldtype functions similarly to the Country Fieldtype. However, in order to determine which regions of a country should be displayed, you need to configure them using the Country config.

The Country config offers two options:

  1. Manual - This option allows you to manually select a country. <img src="readme/images/region_config_country_manual.png" alt="Region Fieldtype config country manual option" />
  2. Field - By choosing this option, you can define the handle of a Country Fieldtype that is within the same blueprint. When a country is selected in the Country Fieldtype, the Region Fieldtype will dynamically update its list of regions to correspond with the selected country. <img src="readme/images/region_config_country_field.png" alt="Region Fieldtype config country field option" />

Region in Country Fieldtype

The Region in Country Fieldtype is a combination of the Country Fieldtype and the Region Fieldtype. In order to select a region, the country must be chosen first. This selection of the country dynamically updates the available options in the Region Fieldtype.

<img src="readme/images/entry_region_in_country.png" alt="Region Fieldtype config country manual option" />


Locale configuration

Control Panel

In the control panel these Fieldtypes are designed to support different locales. This means that when you change the locale for the control panel, the fieldtypes will be displayed in the corresponding language.

To configure the locale of the control panel, you need to set the locale value in the config/app.php file. Don't forget to run php artisan config:clear afterwards to ensure the changes take effect.

Multi site

When using multi-site, rendering one of the Fieldtypes in an Antler {{ region }} will display the value in the language specific to the site's locale.

The configuration for these locales can be found in the config/statamic/sites.php file.


countries_and_regions tag

Iterate over countries or regions in antlers with the countries_and_regions tag.

Countries countries_and_regions:countries

The param default can be used to set selected to true for the country that matches.

Example use in a register form:

Regions countries_and_regions:regions

The param country can be used to filter for a country by code. This can also be multiple: "AU,US". The param default can be used to set selected to true for the region that matches.

Example use in a register form:

If you have a country select above a region select please see the below subheading.

Endpoint: /countries_and_regions/{countryCode}/regions

If you have a country select above a region select and you want the region options to update when the country is selected. Then see this example:


All versions of statamic-country-and-region-fieldtypes with dependencies

PHP Build Version
Package Version
Requires statamic/cms Version ^6.0
sokil/php-isocodes Version ^4.1
sokil/php-isocodes-db-i18n Version ^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kadegray/statamic-country-and-region-fieldtypes contains the following files

Loading the files please wait ...