Language:


Country Selection

This page describes allowing browser users to select a country, together with some of the consequences of that choice. It describes the following Structure Type:
  • Redirect to Country Sub Page
And the following Element Types:
  • HAL Function (with worldmapcontrol) (Element includes a selection list that browser users will be able to use to change country)

  • Country Name (Element displays the name of the selected country)
All the settings and registers mentioned on this page are located in the Webshop and CMS module unless otherwise specified.

---

If you have configured your website to be viewable in different languages, you might need browser users to specify a country as well (or instead). This has the following benefits:

  • When a browser user chooses a country, the display language can be changed automatically as a consequence (i.e. you do not need browser users to choose both a language and a country separately).

  • Instead of offering translations of the same pages to users in different countries, you can display completely different pages depending on the country.

  • If you have a multi-Company database and you need users to log in to different Companies, asking them to select a country will ensure they log in to the correct Company. Please refer to the Webshop in a multi-Company Database page for details.

  • The Web Statistics report allows you to see page views by users in different countries.
Follow these steps:
  1. When browser users choose to change country, they will be shown a list of options. You can construct this list in one of two ways:

    1. You can create a simple list of countries.

    2. You can divide the countries into regions, so that browser users will first need to choose a region and then a country.

    If you want to use the second option, use the Country Regions setting to define your regions, which could be the continents of the world or any other regional divisions as necessary.

    Note that this is not the same setting as the Country Regions setting in the System module.

  2. Enter separate records for each of the countries that you need in the Countries on Web setting.

    Code
    Enter a unique Code for each Country. Although you can use arbitrary codes, it is usually recommended that you use the two-character ISO 3166 codes for each Country.

    ISO Code
    Enter the two-character ISO 3166 code for the Country here.

    Text
    Enter the name of the country as it is to be shown on your website. If necessary, enter translations of this name in the matrix below.

    By default, when browser users choose to change country, they will be shown a list of options displaying the Text from each record in this setting. You may therefore choose to enter Texts in the native languages of each country so that browser users will be able to identify their own country. An alternative is to enter Texts in your language and list translations of each country name in the matrix. This will mean that the country names in the list of options will change when a browser user chooses a different language.

    Region
    Paste Special     Country Regions setting, Webshop and CMS module
    If you decided to use the second option in step 1 (i.e. browser users will first choose a region and then a country), use this field to assign each country to a region. If you do not assign a particular country to a region, it will be included in the first list of options (i.e. the list of regions).

    Default language
    Paste Special    Languages on Web setting, Webshop and CMS module
    If you need the display language used in the website to be changed automatically when a browser user chooses a country, specify the new language here.

    Allowed languages
    Paste Special     Languages on Web setting, Webshop and CMS module
    If a browser user chooses a country, they will also be able to choose a language separately if you have included a "Language Switching Combo Box" Element in your site. By default, the drop-down menu in this Element will list every language that you have included in the Languages on Web setting. If you want this drop-down menu only to list the languages that are spoken in a particular country, list those languages in this field, separated by commas. If you have specified a Default language in the field to the left, you should include that language in this field as well.

    Show on web
    Select this option if you need the country to be included in the list of options offered to browser users when they need to choose a country.

  3. Add a record to the Structure register to define the URL of the country selection page, add a Page and then add the relevant Elements. Include an Element in which the Type is "HAL Function" and the Parameter/URL is "worldmapcontrol":

  4. Add a button or menu item that will take browser users to the country selection page i.e. to the Structure or Node that you added in step 3.

  5. This is the country selection page in a browser:

    In this illustration, the following <div> attribute is user-assigned (i.e. you can assign a different attribute or choose not to assign it at all):

    • id="content" (specified in the "COUNTRYSELECTION" Element)

    The following attributes are assigned automatically by Standard ERP (i.e. you will not be able to change these attributes, but you will be able to apply styling to them in your .css file):

    • <div id="map0">, <div id="map1">, <div id="map2">, etc (blank <divs> for layout/formatting)

    • <a id="mapregion"> (blank anchors for each region)

    • <div id="mapText"> (wraps the unordered list containing the regions)

    In this example we have divided the countries into regions (as mentioned in step 1) and so the "HAL Function"/worldmapcontrol Element lists the regions under the heading "Choose your region" (Web Text 25301). If you are not using regions, the countries will be listed instead, so you may need to use the Web Texts setting to change the heading.

    When a browser user chooses a region, they will be shown a list of countries in that region:

    In this illustration, the following <div> attribute is user-assigned (i.e. you can assign a different attribute or choose not to assign it at all):

    • id="content" (specified in the "COUNTRYSELECTION" Element)

    The following attributes are assigned automatically by Standard ERP (i.e. you will not be able to change these attributes, but you will be able to apply styling to them in your .css file):

    • <div id="map0">, <div id="map1">, <div id="map2">, etc (blank <divs> for layout/formatting)

    • <a id="mapregion"> (blank anchors for each region)

    • <div id="mapText"> (wraps the"(<< Back)" link (Web Text 25509) and the unordered list containing the countries)

    • <div id="countrybackbutton"> (wraps the "(<< Back)" link)

    • <ul class="col1"> (wraps the unordered list containing the countries) (if there are more than 15 countries, there will be separate unordered lists each containing a maximum of 15 countries and with class="col1", class="col2", class="col3", etc)

  6. An alternative to the "HAL Function"/worldmapcontrol Element is to use a "Plain HTML" Element with a connected Translation that contains hard-coded calls to WebAction.hal. As it is unlikely that you will need to update the Countries on Web setting very often, the cost of using hard-coded calls will be small. This method will be useful if you want to present the options in your own way (e.g. links marked with flag icons).

    The syntax of the calls to WebAction.hal should be as follows:

    <a href="/WebAction.hal?action=changecountry&country=language_code&path=/Web_structure_name"></a>

    The path parameter is optional and allows you to specify where the browser user should be taken after choosing a country. If you do not specify a path, the user will be taken to the home page. If you need users to remain on the same page, add an Element to the "HTML Head" Rel. Position of each Page containing JavaScript that places the path of the current page in a variable.

  7. If you have different domain names for each country, you can have a country selected automatically depending on the domain that a user visits. To do this, create separate records for each domain in the Mappings Hostname/Country setting:

    Each record will connect a domain name to a country.

  8. If you would like to display the name of the selected country, add an Element in which the Type is "Country Name" to your header Element or template Page:

    A "Country Name" Element does not need a Translation and indeed any connected Translations will be ignored

    If a browser user has not selected a country, the "Country Name" Element will by default display the word "global". If you need to change this word and/or enter translations, add a record to the Countries on Web setting in which the Code is "global" and with an appropriate Text and translations in the matrix. You can leave the Text field blank if you do not want anything to be displayed (leaving the Text field blank will also mean this record will not be offered as an option when a user chooses a country).

    The "Country Name" Element simply displays the name of the selected country. You cannot use an Element of this Type as a link or button on its own. If you would like the button or menu mentioned in step 4 to have the selected country as its label, use the "Country Name" Element but enclose it in a parent Element, and surround it with same-level Elements that will open and close the anchor tag. In this example we will include the "Country Name" Element in the label of a menu item:

    1. Add the parent Element (a "Plain HTML" Element). As this Element will in effect be a menu item, it does not need its own <div> because it should share its formatting with the other menu items. We have therefore selected the Don't wrap in <div> option. In this example we have already named the three subordinate Elements:

    2. The first subordinate Element should also be a "Plain HTML" Element. This Element should have a connected Translation that opens the anchor tag. In this example, we have used a relative link to the Structure or Node from step 3 (using its Web structure name "countryselection") and also included some static text:

    3. The second subordinate Element should be the "Country Name" Element illustrated at the beginning of step 7. This will display the name of the selected country (or "global" if no country is selected).

    4. The final subordinate Element should have a connected Translation that closes the anchor tag. As in the parent Element, we have selected the Don't wrap in <div> option in all three subordinate Elements so that the end result will appear to be a normal menu item:

    5. Specify the parent Element in the Show as Web Element field in the Menu record:

    6. This is the result in a browser:

      When the browser user uses the menu item to select a country (following the process described in step 5 above), the label of the menu item will change to display the selected country:

      In this example, the language of the page has also changed, to the Default language specified in the relevant record in the Countries on Web setting.

      After a browser user selects a country, the country code ("FR" in this example) will be inserted in the URL automatically.

The steps so far allow browser users to choose a country and then to be shown each page in the appropriate language. The pages will have the same templates and Elements so the only changes will come from the Translations. It may be that you need to display completely different pages depending on the country. Follow these steps:
  1. Add records to the Structure register for the default versions of each page (e.g. the home page, the "contact us" page, the "about us" page, etc). Select "Redirect to Country Sub Page" as the Type.

    A "Redirect to Country Sub Page" Structure or Node acts as a "Parent Node". Each Parent Node can have a number of Child Nodes (one for each country) which you will enter in the next step. When a browser user who has selected a country goes to a particular page, they will be taken to the Parent Node and then redirected to the selected country's Child Node. If there is no Child Node for the selected country, they will remain at the Parent Node.

    In this illustration, we have changed the Type of our existing home page from "Page" to "Redirect to Country Sub Page":

  2. Create separate Structure records for each Child Node:

    Parent
    Paste Special     Structure register, Webshop and CMS module
    Enter the Code of the Parent Node (i.e. the Structure record from the previous step).
    You can create Child Nodes from the Parent Node by selecting 'New child node' from the Operations menu. Using this method, the Parent field will be filled in automatically.

    Web structure name
    Paste Special    Countries on Web setting, Webshop and CMS module
    Enter the code of the country from the Countries on Web setting.

    Type
    Paste Special    Choices of possible entries
    Set the Type in each Child Node to "Page".

    Page
    Paste Special    Page register, Webshop and CMS module
    Having a separate Structure record for each Child Node (i.e. for each country) allows you to use different Page records which in turn means you can use different templates and menus.

    The Child Nodes will be listed at the bottom of the 'Web Structure: Inspect' window for the Parent Node. You can double-click any Child Node in the list if you need to edit it:

  3. In this step, enter the Pages, Elements, Translations and Menus that you need for each Child Node.

  4. Repeat steps 8-10 for other pages as necessary. As the Web structure name of a Child Node must be a country code from the Countries on Web setting, the result will be many Child Nodes with the same Web structure names.When a user changes country, the page they will be taken to will be chosen as follows (in all cases they will be taken to the correct Child Node for the selected country):

    1. If the user changed country using a "HAL Function"/worldmapcontrol Element and if you are not using regions, the user will be taken back to the page where they were previously.

    2. If the user changed country using a "HAL Function"/worldmapcontrol Element and if you are using regions (i.e. the user will first need to choose a region and then a country), the user will be taken back to list of regions.

    3. If the user changed country using a call to WebAction.hal (step 5 above), the user will be taken to the page that you specified in the page parameter. If you didn't include the page parameter, the user will be taken to the home page.
You can use the Web Texts setting to change the following texts:

Element TypeDefault TextWeb Text Code
HAL Function/worldmapcontrolChoose your region25301
HAL Function/worldmapcontrolChoose your country25302
HAL Function/worldmapcontrolBack [the brackets and the "<< " prefix will be added automatically] 25509
HAL Function/worldmapcontrolOther25300

---

Languages and Countries:

Go back to: