Country list and city list

foodbo - August 12, 2009 - 09:57

Hi there,

I am trying to list all the countries from a drop down list, then list all the cities in the selected country.

does the Location module do the job or other better way to do?

many thanks.

Not sure which is the best

adam_b - August 12, 2009 - 12:05

Not sure which is the best module, but are you aware how long this list will be? Even listing every country and its states/provinces gives thousands of entries (see http://www.commondatahub.com/live/geography/state_province_region/iso_31...) which makes it impossible to display in a drop-down list.

Thanks for the input. Well,

foodbo - August 13, 2009 - 07:26

Thanks for the input.

Well, It would be difficult to list all in a drop down list but, what i would like is a bit like the hotmail registration, which list about 100 countries in a drop down list, then depends on which country is selected then only display all cities ( or just the main cities) in the second drop down list.

any idea how can i do that?

thx

Taxonomy is the easiest

Valentin Matresu - August 13, 2009 - 02:14

You can use the import feature for Taxonomy. Just create two vocabularies one for country and one for cities. Then for each city you will have to specify the country.

You can use this module: http://drupal.org/project/taxonomy_manager

thanks vmatresu, I have tried

foodbo - August 13, 2009 - 07:31

thanks vmatresu,

I have tried the demo of the module, it maybe too long to list all the countries on a page??? so can you just specify just to select only one entry?? and can that be displayed within a "scroll down" panel??

thx.

anyone has anymore idea / example would be appreciated, thx.

Example

Valentin Matresu - August 13, 2009 - 12:38

This is how I implemented something similar (with taxonomy etc). You can see example here: Vanzari afaceri The website is in romanian, but you can see the dropdown named Judete (Counties) in the top left.

Also please see an advanced view here: Afaceri de vanzare where it's in another format.

Don't forget that view has pagination (how many items per page) and you can limit the number of items if you want to have less.

You can use my contact if you need more detailed information, but I think you can do it with taxonomy. I use Taxonomy manager and it's pretty good because you can delegate to other users and they can create new terms using a nice interface. You give users permission on just certain taxonomy types.

Valentin

I would like to know a bit

foodbo - August 14, 2009 - 07:24

I would like to know a bit more detail of how u did that as well, i have installed CCK, and taxonomy_manager and enabled taxonomy, also managed to import all the countries. so how can i display in a drop down list??

many thanks.

Views + taxonomy

Valentin Matresu - August 14, 2009 - 08:34

Basically once someone selects a country and a city a page should show, or whatever happens. This result you can put in a view.

Using the Views module is really easy.

You would follow the steps:

1. new node view, name it whatever
2. Chose output: Page or block (in my case it's a block
3. Under Page settings you can set what the url will be (you can style the result of the view later using css and a tpl)
4. Select the fields that you want shown (the result ) - this is under Fields
5. Now we create the dropdown as Filters : click on +, add Your_Content_Name.Countries, as a filter chose is one of and Force single (this means drop down, otherwise it will be a select box, where you can select more than one) and set this filter to exposed (this means it will show up so the user can configure it, otherwise is just for sql)
6. Add more fields/filters, you can add arguments, order of output etc.

Save the view and then you just need to go to blocks to show this block in your page (when you create a view in blocks mode, it creates a block that shows up in block administration).

Using views you can create really nice things, and it's a bit difficult to understand in the beginning how it works (especially if you don't have any DB experience), but afterward is really helpful.

I wanted to send you some screen caps so you could follow easier, but I don't know how to attach it here. You can use my contact and send me an email and I will email it to you or smth.

thx, i think i know what u mean.

foodbo - August 14, 2009 - 12:13

not sure, am I misunderstand you. The result (cities) will be displayed on a view page or block page?? But it is possible to list all the result in another dropdown list as well??

my email address is bbx1000 (at) hotmail.com

thanks for you help.

Hi, How can you specify the

Summit - November 8, 2009 - 14:48

Hi, How can you specify the country for the city please? I do not understand this..sorry?
I understand having two vocabularies, but not how to relate them to each other.
Thanks a lot in advance for explaining this!
Greetings, Martijn

Greetings,
Martijn
if you appreciate e-development work, please place a link from your site to www.trekking-world.com

Use taxonomy, and make cck

oboskovic - August 13, 2009 - 09:25

Use taxonomy, and make cck fields with hierarchical select module.

thanks, for the keywords.

foodbo - August 14, 2009 - 07:26

thanks, for the keywords.

I have tried the "hierarchical select" module's demo, it seems exactly what i am looking for but it is still in beta version for drupal 6.

guess i will spend a bit more time to try out this module, do you have any tutorial link or document to share??

many thanks.

Trust me you can use dev

oboskovic - August 14, 2009 - 07:51

Trust me you can use dev version of HS, as long as you don;t use it with Content profile module. It works great.

the problem is i am using

foodbo - August 14, 2009 - 08:37

the problem is i am using content profile module as well, so what kind of known bugs with that??

another thing is how can i easily to import the cities for the country? I have imported the country list now... then what is the next step??

Ok, just read the issue for

foodbo - August 14, 2009 - 12:49

Ok, just read the issue for content profile and HS. http://drupal.org/node/348677

so the problem won't fix for a while then

i am testing it anyway, i have imported a few cities for testing, so how can i create a CCK field on my profile for that?? do i need another CCK field module??

Content Taxonomy

foodbo - August 14, 2009 - 15:10

it seems I need the "Content Taxonomy" for CCK field ?? but only support drupal 5 at the moment. or another way to do?

seems a very common thing to

foodbo - August 17, 2009 - 05:19

seems a very common thing to do but why it is so hard in drupal???

anyone got more suggestions / examples??

many thanks

easy way to do that

Yura - August 20, 2009 - 20:46

easy way to do that you are looking for... check this one option trim

 
 

Drupal is a registered trademark of Dries Buytaert.