Tassos Marinos Developer of Joomla Extensions

ACF Country - Add a Country dropdown field in Joomla

Updated 03 Jul, 2023

The Country custom field gives you the ability to select one country or more through a list of countries by displaying either it's name or code name. The Countries field also allows you to detect your country via your IP Address so it will prepopulate the field for you.

How to add a Country Custom Field to Joomla! Articles

To add a Country Field on Joomla Articles, go to Content > Articles > Your Article > General Tab > Select ACF - Country Type.

acf-country-field-settings

Below we will describe each field's options.

Name Description
Name The name will be used to identify the field. Leave this blank and Joomla will fill in a default value from the title.
Label The label of the field to display.
Description A description of the field that will be displayed in the label tooltip.
Required Is this a mandatory field?
Return Value Specify the return value on front-end.
Choose between country name or country code to appear on the front-end.
Multiple Country Selection Allow selection of multiple countries..

Pro Options

Name Description
Detect Visitor Country If enabled, the field will try to detect and prefill the visitor's country.

It requires the TGeoIP plugin to be installed.

Usage

Once you are in your Article's Edit screen, choose the "Fields" Tab to see the Country custom field as you can see in the screenshot below.

acf-country-usage

This selectbox contains all the countries of the world and you can fast search the one you want just as you type in.

Frontend Display

Take a look at the screenshot below to see how it could be displayed in your frontend.

acf-country-frontend

Frequently Asked Questions

How to display countries by their names or code names

The setting that handles how to display the countries, with their name or their code name, is called Return Value and by default is set to Country Name. This means that on the front end, countries will appear with their full name.

If you want to display countries with their code name, you will need to select the option Country Code on the setting Return Value which in return, will make countries appear with their Code Name (Example: Greece will appear as GR).

How to select multiple countries

By default, the setting Multiple Country Selection is disabled which means you will only be able to select a single country in the Article's Fields Tab.

If you desire to select more than one country you will need to enable the setting Multiple Country Selection, which in return will allow you to select multiple countries in the Article's Fields Tab.

How to detect visitor's country and prepopulate country list

With this setting, called Detect Visitor Country, you can detect the visitor's IP Address and prepopulate the country field. What it does is it takes the IP Address of the visitor and translates it to a country. The GeoIP plugin must be enabled in order to work.

To enable the GeoIP Plugin, go to Extensions > Manage and search for "System - Tassos.gr GeoIP Plugin".

Read our full guide on how to set up GeoIP plugin here: How to enable Geolocation features in Tassos.gr extensions

Frequently Asked Questions

How can I override the layout of "ACF - Country" custom field?

To override the "ACF - Country" custom field, read here: How to override the "ACF - Country" custom field.