1

I have a requirement to add additional countries to the location module.

I need to add England, Scotland, Wales and Northern Island.

I suppose they could be provinces, but I can't figure out how to do that either.

Many thanks for any help :)

PS. I would be using the county codes for css so country would be better.

1 Answer 1

4

So maybe my question wasn't worded in the best way, but I have found the answer.

All countries in Drupal (at least in 7) are taken from the /includes/iso.inc file. This includes Location and Address Field.

You can add countries to this list via drupal_alter

An example:

<?php
function hook_countries_alter(&$countries) {
  // Elbonia is now independent, so add it to the country list.
  $countries['EB'] = 'Elbonia';
}
?>

Putting this in a custom module will enable you to add countries as you require. You must use a 2 letter iso code!

3
  • How about country module and countries api module?
    – Umair
    Apr 16, 2017 at 18:23
  • 1
    There is a countries (drupal.org/project/countries) for D7 that does about the same with an interface, but the others are not aplicable for D7. Apr 17, 2017 at 12:16
  • What would you suggest for country flag icons?
    – Umair
    Apr 18, 2017 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.