Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • dominik 711 posts 733 karma points
    May 09, 2011 @ 13:28
    dominik
    0

    Multiple ISO country code list

    hello,

    I need a datatype for a multiple list with all Countries. The value should be the ISO code for each country.

    Is there any datatype available for this?

    I saw there is a countryPicker but withou ISO codes.

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 09, 2011 @ 19:51
    Jan Skovgaard
    0

    Hi Dominik

    As far as I know such a datatype does not exist - but it should be easy enough to create your own allthough it can be a daunting task depending on how it's approached.

    You can do it either as you own datatype for Umbraco or by creating an instance of the checkboxlist datatype that already exists in Umbraco.

    Or you could create it as a part of a content repository in the content section where it can easily be imported from xml, csv or another database by using the CMSImport package...

    /Jan

  • dominik 711 posts 733 karma points
    May 09, 2011 @ 20:13
    dominik
    0

    but why should i user a checkboxlist? i think a multiple list would be much mor comfortable or?
    And how can i create it. I think there are more than 300 different countries.

    YOu mentioned it should be easy. Perhaps you can tell me how you would create such a datatype including all countries with ISO code

     

    Thanks

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 09, 2011 @ 20:50
    Jan Skovgaard
    0

    Hi Dominik

    I did not say you should use it like it was the only option. I mentioned some other possible options and there are probably more that I have not thought of. It's entirely up to you :-)

    Easy as in if you have the right skills (C#, .NET etc. - I don't I'm a frontend guy :-))

    On how to create a custom datatype you can have a look at Tim Geysens site, for instance have a look at this article: http://www.nibble.be/?p=24

    Hope this helps.

    /Jan

  • dominik 711 posts 733 karma points
    May 09, 2011 @ 20:51
    dominik
    0

    sorry i am also a designer and not a developer so its also really hard for me :D

     

    But thanks for your help

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 09, 2011 @ 20:57
    Jan Skovgaard
    0

    Well...isn't the approach with creating the countries as a content repository an option then?

    If you can find the list of ISO countries somewhere around the net and format it into a CSV file, it should be quick to get the countries imported and then use the repository as the source for which to create the dropdownlist for the website using a XSLT or Razor macro?

    And if you need it to be used on another document type then you could create an instance of the ultimate picker datatype and set the start node id to the one of your country repository...

    does it make sense?

    /Jan

  • dominik 711 posts 733 karma points
    May 09, 2011 @ 21:04
    dominik
    0

    yes there are many lists for this

    http://www.iso.org/iso/english_country_names_and_code_elements

    So formating into a csv list should not be a big problem. What I need is to get this list as a multiple datatype in umbraco so my backend users can pick countries from a property. I then have to use the ISO code of the selected values in an XSLT file.

    At the end i will look if the country of the user is inside this list.

    I got it working with the countryPicker but it uses the Country names and I just want to use ISO codes for countries.

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 09, 2011 @ 21:11
    Jan Skovgaard
    1

    Hi Dominik

    Then I would create a document type called "Country" with two texfield properties called "Country" and "ISO".

    When using CMS import to import the countries from your CSV list you map the country to "Country" and country should also be mapped to @nodeName. ISO is mapped to "ISO".

    Then you have the data in Umbraco.

    Now in the developer section you can create a new datatype called "Country picker".

    Then choose the ultimate picker for this datatype and click save.

    Now you can specify where it should list content from and what kind of list it should act like....checkbox list, radio button list or dropdown list.

    When you have saved these settings for the datatype you can use it on your textpage where it will show a nice dropdown list with the country names.

    When a country has been selected you can fetch the country ID in your XSLT file and use this value in umbraco.library:GetXmlNodeById() so you can fetch the XML for the chosen country and the get the ISO codes.

    Would this work for you?

    /Jan

  • dominik 711 posts 733 karma points
    May 09, 2011 @ 21:18
    dominik
    0

    ok and the cms import is integrated in umbraco?
    or have i to install this extension?

    So i have to create own documenttype to create a new datatype?

    Is it necessary to create a document type for it? Can i not directly add a datatype including a list in this way:

    General:<option value="ISO-CODE">Country Name</option>
    Example: <option value="DE">Germany</option>

    So mutliple select should be possible.

    I do not understand why i have to create document type for it

    Thanks for all of you help

     

     

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 09, 2011 @ 21:29
    Jan Skovgaard
    0

    Hmmm...

    how would you like to have the countries displayed on your website?

    Should it be a dropdown list on the website also?

    What I thought was that it should be possible to select a country on a node in the backoffice from a country dropdown?

    Please give some examples on the usage and hopefully I can provide a better answer :-)

    /Jan

  • dominik 711 posts 733 karma points
    May 09, 2011 @ 21:34
    dominik
    0

    i just need it in the backend for the admistrators. They should be able to selecte one ore more countries via a multiple list.

    In an XSLT script i will check if the country the user is in is inside the selected values (ISO codes).

    Until now i am using the multiple countryPicker (uComponents) but this datatype uses the countryNames as value and not any ISO code.
    In the mediatype i created a new property using this multiple countryPicker list and it is working. But i want to use ISO codes instead of countryNames

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 09, 2011 @ 21:37
    Jan Skovgaard
    0

    Just to make sure I get it 100% - So on the website the ISO code for a country should be shown, right?

    /Jan

  • dominik 711 posts 733 karma points
    May 09, 2011 @ 21:39
    dominik
    0

    no on the webpage nothing should be shown i just need the information for my macro so i can show different images for different countries.

    SO what will happen:

    I get the country of the user in the background and will look if the country is inside the selected list (of the admin) and shows the image only if the country is inside this list :-)

     

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 09, 2011 @ 21:51
    Jan Skovgaard
    0

    Hehe, ok then it's falling into pieces for me...

    But yes, if you choose to follow my approach you will need to install CMSimport, since it's a 3rd party package and it's free as long as you don't need to import more than 500 nodes.

    The reason why you need to create the countries as nodes is because you need a source to feed the ultimate picker with the values.

    In your content section it could look like this

    Homepage
       - page
       - page
       - page
       etc.
    Countries
       - country
       - country
       - country
       - etc.

    Here you have a "Countries" repository, which is suggest you create by making a placeholder document type named "Countries" and then you make the Country document type, which is allowed under "Countries". The properties for the "Country" document type should two textstrings, 1 for country and one for ISO.

    Then you can create an instance of the ultimate picker in the datatype folder under the developers section.

    Here you set the start node id to the id of your "Countries" repository.

    Now on your "Page" document type or what you call it you can select this datatype to get the list of countries to choose from.

    Then in your XSLT you can pass the id of the selected country node to the GetXmlNodeById() extension so you get the XML returned, where you can then fetch the ISO code and do your magic :-)

    Ideally this would be created as a custom datatype...and without a doubt someone else in here knows how to do it :-) But if you can use this method to move forward it's great and you have learned to see solutions in another perspective :-)

    I hope this makes sense.

    /Jan

  • Lennart Stoop 304 posts 842 karma points
    May 09, 2011 @ 23:52
    Lennart Stoop
    1

    I wasn't sure what I wanted to code tonight, and this thread kinda made me eager, so here's what I came up with:

    http://our.umbraco.org/projects/backoffice-extensions/countrypickeriso2

    I sure hope you're using Umbraco 4.7 ;-)

  • dominik 711 posts 733 karma points
    May 10, 2011 @ 07:50
    dominik
    0

    Wow great - i like this community

    You are really great

    I will try your plugin

    Thanks a lot :-)

    Yes i am using Umbraco 4.7 and .Net 4.0

  • dominik 711 posts 733 karma points
    May 10, 2011 @ 07:58
    dominik
    0

    Its working great

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 10, 2011 @ 08:09
    Jan Skovgaard
    0

    Hi Lennart

    You rock man! :-)

    /Jan

  • Lennart Stoop 304 posts 842 karma points
    May 10, 2011 @ 08:40
    Lennart Stoop
    0

    No worries, seemed useful and was in the zone, glad to hear it works :-)

     

  • dominik 711 posts 733 karma points
    May 10, 2011 @ 13:41
    dominik
    0

    Ok it works really good.

    Now ive got a global question about how to solve it.

    If i want to select all countries which are inside the European Union (EU) how can i achieve this?

    Any solutions for it?

    It would be really hard to select each country :-)

    Perhaps a button called "only EU countries" which select automatically all european countries?
    I then have to set up this list only once.

    i need the possibililty of selecting countries in the way it is working now  but also to select just for example all european countries :-)

    Anybody any idea how to solve this?

  • Lennart Stoop 304 posts 842 karma points
    May 10, 2011 @ 19:37
    Lennart Stoop
    1

    Hmmm, that's a very specific implementation.

    Maybe I could make it a bit more generic by allowing you to apply a "filter" on the listbox, for example a dropdown with named filters like "Europen Union" or "Scandinavian", and allow you to configure these filters yourself (add a filter name, and a list of ISO2 codes associated to that filter).

    When you then apply a filter, the associated countries are selected (and all previous selections are removed).

    I'll see what I can do :-)

     

  • dominik 711 posts 733 karma points
    May 11, 2011 @ 07:55
    dominik
    0

    Oh this sounds really good :-)

    Filter seems to be a good method but there should also be the possibility of selecting each country in the multiple box

    it will also be great if i can make  my own filters

     

    Thanks for all of your help

     

  • Lennart Stoop 304 posts 842 karma points
    May 11, 2011 @ 23:32
    Lennart Stoop
    0

    Hey Dominik,

    I have uploaded a new version of the package, which now contains the optional filters as proposed.

    The UI has been slightly modified: a second listbox was added which now holds the selection (to avoid confusion when filters are applied).

    No changes were made to data storage, so you shouldn't have any problems with existing data.

     

    To configure any filters, check out the screenshot of the data editor settings, that should give you an idea :-)

    http://our.umbraco.org/projects/backoffice-extensions/countrypickeriso2

  • dominik 711 posts 733 karma points
    May 12, 2011 @ 07:49
    dominik
    0

    Wow!

    You are really great! this rocks :-)

    Thanks so much

Please Sign in or register to post replies

Write your reply to:

Draft