Country selector v0.1

Release Notes

- initial release

  • @Jerome great plugin thanks. I have extended it a bit to include provinces/regions for the following countries: UK, AUS, NZ, ZA (South Africa), Ireland, CN (China) however my extensions don't follow the ISO 3166 model.

    If you would like a copy send me a private message.

    Thanks again for a great plugin.

  • How does this work...AT registration time>? Configuration?

  • This plugin works with the profile_manager plugin provided by those nice guys at ColdTrick.

    1. Enable plugin in Tools Administration
    2. Open "Replace Profile Fields" in Admin backend
    3. Add profile field (look in field types, at bottom is "Country" & "Province)
    4. This plugin's fields are automatically set to appear on your registration page.

    hth

    @Jerome - I would love to see the province dropdown read from the country dropdown and only display relevant provinces. Parent values of provinces set to country values would be a good start.

  • @DJuse: like Trajan said it works with Profile Manager, but mostly i created this plugin for other plugin developers so they don't have to create the code to get the lists.

    @Trajan: it would be nice to get the state field to listen to the country field, however I don't know if both fields are availible on a form. Or if there is more than one country field (eg birth country, current country, working country) which should the state field listen to?

  • @Jerome I see your point. Not that I want it to be like facebook but they do provide an example format to consider. They set their systemup as birth/nation country and have attached provinces to fit with that.  Then current location is a textfield. It is one way to look at it.

    But yes your point about if there are 2 country fields which one should the province listen to is valid. Could this be done by setting a parent value for province field inside of profile_manager perhaps. Set the parent value to the value of the country field? I imagine this would be a profile_manager edit not a country_selector edit. I'm not a coder, but something like this perhaps?

    province field:

    check if any country fields on form
    if yes count
    if only 1 -- align with country field
    if more than 1 -- show notification/error (must set parent value for this field)

    add text field for setting parent value where user should type in value of country field.
    check that value entered is of type "country" field
    if yes -- ok
    else -- error (the field you selected cannot be used as a parent)

    Perhaps something like this would work?

     

  • How about treating the Country/Region/City as one element in the profile manager instead? (I'd like to see City added, BTW) That would allow the Region field listen to the Country field more easily. After all, I belive that most users would be fine with being forced to show Country then Region then City rather than not have the fields listening to each other. Just a thought.

  • Great, easy to use, took 30 secs to integrate into my own plugin. Thanks!

  • @Jerome  anyway to extend a bit further? 

    City select for each state?

  • How can I do to put the states of other countries?

  • @gastre:

    overrule /mod/country_selector/views/default/input/ca_us_state.php in your template with all the states of the other countries you would like to support.

  • @Jerome, Thanks.

    And is possible to do if I  pick one countri (usa) the states of usa.

    If I pick (germany) the states of Germany.,e tc...

    ???

  • @gastre: anything is possible, however this plugin wasn't made for it. If you want this you should program it yourself

  • Rather interesting requirement !

    Some months I had developed something similar for a client to handle cities, states input and auto-populate -- where Address is specified as Postal Code, Department, City, France. The States/ City data was about 1.5 MB.The data dump for UK is abt 5MB, AUS abt 1MB,... and so on.

    So *IF you wanted to cater for *all the countries; states/ cities in the world, you're probably looking at 1/2 GB of data ;-) In general each individual country's state/ city data tends to abt 1MB - 8MB.

    What I discovered and learned during that project was that "*anything is possible..". It sometimes, most of the time just takes a fair amount of effort - maybe a few hours, maybe several days -- to get the necessary data set up to provide such advanced fancy features...

  • @dhrupDeScoop, thanks..

    I only want to put 6-7 countries.

    But the problem is that I don't want to I select one country, and then I have to choose betwen 7 diferents forms.

    I want to if I select france "only appear the states of France" and if I select "spain" only the states of Spain.

    This is possible with profile manager???

    thanks.

  • I only want to put 6-7 countries.

    But the problem is that I don't want to I select one country, and then I have to choose betwen 7 diferents forms.

    I want to if I select france "only appear the states of France" and if I select "spain" only the states of Spain.

    This is possible with profile manager???

    thanks.

    short answer => no

  • gastre , you can use this JS code for that :

    ----------------------------------------------------------------------------------------------

     

    <form name="choice"> <p>

    <select name="A" size="1" onChange="change(this.options.selectedIndex)">

    <option>United state</option>

    <option>Spain</option>

    <option>Germany</option> </select>

    <select name="A2" size="1">

    <option value="city0_of_US">city0_of_US</option>

    <option value="city1_of_US">city1_of_US</option>

    <option value="city2_of_US">city2_of_US</option> </select> </p>

    <script type="text/javascript">

    <!-- var groups=document.choice.A.options.length var group=new Array(groups) for (i=0; i<groups; i++) group[i]=new Array() group[0][0]=new

    Option("city0_of_US","city0_of_US") group[0][1]=new

    Option("city1_of_US","city1_of_US") group[0][2]=new

    Option("city2_of_US","city2_of_US") group[1][0]=new

    Option("city0_of_SP","city0_of_SP") group[1][1]=new

    Option("city1_of_SP","city1_of_SP") group[2][0]=new

    Option("city0_of_GER","city0_of_GER") group[2][1]=new

    Option("city1_of_GER","city1_of_GER") group[2][2]=new

    Option("city2_of_GER","city2_of_GER") group[2][3]=new

    Option("city3_of_GER","city3_of_GER")

    var temp=document.choice.A2 function change(x){ for (m=temp.options.length-1;m>0;m--) temp.options[m]=null for (i=0;i<group[x].length;i++){ temp.options[i]=new

    Option(group[x][i].text,group[x][i].value) } temp.options[0].selected=true } //-->

    </script> </form>

     

    --------------------------------------------------------------------------------------------

     

  • Is there an update for this?

Jerome Bakker

Developer @ ColdTrick IT Solutions

Stats

  • Category: Third Party integrations
  • License: GNU General Public License (GPL) version 2
  • Updated: 2014-11-17
  • Downloads: 2764
  • Recommendations: 8

Other Projects

View Jerome Bakker's plugins