This module implements the Hierarchical Select widget API to provide a widget for selecting a Geoname.

The widget is very demanding on the web service, so it's crucial that you've set up Geonames to cache result data for a good amount of time.

CommentFileSizeAuthor
hs_geonames.module.txt1.48 KBAnonymous (not verified)
hs_geonames.info212 bytesAnonymous (not verified)

Comments

andreiashu’s picture

unbelivable !!!
I just need this :)
I'll test this out and give feedback here

andreiashu’s picture

hmm.. oki. stupid question: how do I test it out ?
Do I have to write some code or it should be somewhere in the UI ?

Anonymous’s picture

It's a HS widget, so you need to create a form that wants a Geonames ID.

andreiashu’s picture

Thanks bangpound, that did the trick. It is my first time I'm trying out HS or Goenames modules.
The module itself works great. I also tested the '#default_value' option and works like a charm.

I only had a small issue: the 'max_allowed_packet' property from my.cnf that was set too low - but of course this is a server issue.

I have one question, maybe you can give me some advice: what would be the best way to store the selected data from the created form element ?
Right now I'm using a hook_form_alter to inject this hs element into the node edit form and in a validate function I assign the selected geonameid to a CCK text field. Is there another better solution ?

Thanks for your time.

Anonymous’s picture

CCK may raise issues that I've not encountered yet. I'm using the element on a custom form which has a custom submit handler for capturing and storing the value. I'm not using it on nodes or with CCK.

Hierarchical Select doesn't have any modules that work with CCK, does it? I think any limitations about this module would be common to HS.

If you're working only with a single valued field, you might try replacing the element type in hook_form_alter, but you'd be experimenting in ways I've not!

andreiashu’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for the info. I think it is worth researching some more about HS with CCK but I'm sure I'll find a lot info in the issue queue.

About this little but very nice module (I'm still playing with it, no problem so far): will you make a separate project for it or maybe try to see if the maintainers of Geonames adopt it ? It would be a pity if it would remain just here as an attachment to this issue.

Anonymous’s picture

Right now, I think it belongs with Geonames. I have a module in development that depends on HS, Geonames and Location_Taxonomy. The developer of HS said that my work on this widget belongs with Geonames.

andreiashu’s picture

Just bumping this so maybe a Geo maintainer sees it.

Anonymous’s picture

had to read this discussion here for several times till i got it that this modulish thing will only work in some kind of self-fabricated forms?

i hoped that this would had to do sth with taxonomies and stuff.
i was eagerly looking for some way to create a vocabulary with country names and their subdivisions and that perfectly sounded like a solution.

have been looking for any kind of prefabricated xml files of countries with their subdivisions and cities before, but that does not seem to exist. the only thing i found was that huuuge 170mb allcountries file from geonames.org, but i see no way to make use of that.

as HS is able to work with cck and with content taxonomy, i wonder if there is any kind of way to provide nodes with the geonames data and store the selected terms hierarchically in a vocabulary for georeferenciation of nodes via taxonomy

sorry for my stupid questions
bernd

skolesnyk’s picture

I was thinking about something like that and found this module http://drupal.org/project/nat

So you'd have to have content types: country, state, city, zip code (have them reference each other via http://drupal.org/project/hs_nodereference) and then establish relationship to taxonomy terms.

Now the question is how to import all those massive data files into CCK nodes.

andreiashu’s picture

@bernadotte and @skolesnyk:
I would suggest storing location data as nodes. You can have node types like Continent, Country, City, etc and have relationships between them with nodereferences. We(the company for which I work) are currently doing this for a travel website and everything is working nice. And because locations are nodes you have a lot more flexibility than with taxonomy.
Importing is quite easy: just manually create a few locations and also the relationships between them (CCK nodereferences) and then use Devel module to see how they are structured. Then you can create a small script that parses the xml/text files and creates nodes with the correct references between the nodes.
Hope this helped a bit.

BenK’s picture

Subscribing....

jsimonis’s picture

Ok, I've been trying to figure out how to use this, but can't see how.

I have nodereference fields set up - first ones are regular select, last one is hierarchial. But how do I bring in the Geonames data? I don't see anywhere for doing it.

Thanks.

fp’s picture

@andreiashu

Could you post the code you are using to test #4??

Thanks :)

andreiashu’s picture

@fp sorry I don't really remember that much. It was more than 1 year ago and my memory sucks.

greg.harvey’s picture

Soooo... this looks cool. Anyone planning to add this to the Geonames package, or should it be its own project?

dgastudio’s picture

can it be ported to d7?

gcoxdev’s picture

Issue summary: View changes

See my sandbox project for D7 version. If anyone is interested in contributing please let me know. https://www.drupal.org/sandbox/gcoxdev/2350771