Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Howdy,
similarly to what was asked for 5.x at http://drupal.org/node/137405 , it's important IMO to have autocomplete work also for City field, as this would cut down on confusion, duplicates and input time.
There's a patch in the mentioned issue, but it does not apply to 6.x, or at list i couldn't find the City handler anywhere ['#title' => t('City') ]. Can anyone give a hint please? many thanks in advance
Comment | File | Size | Author |
---|---|---|---|
#2 | location_autocomplete_cities.patch | 328.26 KB | Roberto Gerola |
Comments
Comment #1
YesCT CreditAttribution: YesCT commentedWhat kind of work flow are you thinking?
I'm thinking to be useful it would be: users enter country first, then state, then an auto-complete city value.
Or were you thinking of something else?
Tagging.
Comment #2
Roberto Gerola CreditAttribution: Roberto Gerola commentedHi.
I developed a patch for this.
The development has been sponsored by Marco.
Roberto
Comment #3
YesCT CreditAttribution: YesCT commentedComment #4
YesCT CreditAttribution: YesCT commentedComment #5
BWPanda CreditAttribution: BWPanda commentedApplied patch, but cannot work out how it's supposed to work... The city field doesn't turn into an autocomplete field automatically, am I supposed to do something to activate it?
Comment #6
marcoBauli CreditAttribution: marcoBauli commented@BWPanda: you need to fill in the list of the cities of your country in /location/supported/location.COUNTRY.inc with the following function:
Comment #7
BWPanda CreditAttribution: BWPanda commentedAh, I didn't realise that was how it was going to work...
I figured since there are are so many more cities around the world than countries or provinces, that to save admins having to enter all cities initially, it could work similarly to the autocomplete taxonomy - users start typing a city, if it exists, it appears in a drop-down list to select from, if not, they finish typing it and it's added to the list of available cities for future.
Would this not be a better implementation, considering the number of cities around the world...? (I need world-wide cities, not just Australian ones)
Comment #8
Xabi CreditAttribution: Xabi commentedCities names are included in the postal code databases, why to re-enter them again?
Comment #9
artatac CreditAttribution: artatac commentedsubscribing
Comment #10
YesCT CreditAttribution: YesCT commentedtagging
Comment #11
andrewsuth CreditAttribution: andrewsuth commented+1 for this feature to be added
Comment #12
marcoBauli CreditAttribution: marcoBauli commented@Xabi: you mean zipcodes.country.mysql? there are no city names there, only coordinates.. ?
Comment #13
goron CreditAttribution: goron commentedsubscribing
Comment #14
juicytoo CreditAttribution: juicytoo commentedHi,
Is this somehow related to
http://drupal.org/project/geonames
cheers
Ed
Comment #15
sbydrupal CreditAttribution: sbydrupal commentedApplied the patch. However, in my case, does not seem to autocomplete. Tried to use Cities from Italy as this was included in the patch.
Any information if any body else applied this patch and checked for Cities in Italy as example?
Thanks
Comment #16
webanalya CreditAttribution: webanalya commentedHi,
Does this patch work with location_cck or only with location_node ?
Thanks !
Comment #17
Summit CreditAttribution: Summit commentedsubscribing greetings, Martijn
Comment #18
sandino CreditAttribution: sandino commentedsubscribing
Comment #19
vlooivlerke CreditAttribution: vlooivlerke commented+1 for feature request, but use the zipcode database as it does contain city names.
And how about placing the marker on the city wile still on node creation page, rater than submitting the node first to see the geocoded location.
Comment #20
juicytoo CreditAttribution: juicytoo commentedthere is city names in the file
zipcodes.us.mysql
and
zipcodes.au.mysql
There is a field available for it.
The structure of the zipcodes contains country, city, postcode.
This might be inefficient.
If a user selects
- country first
- system should filter only the cities related to that country.
It might need a seperate table to store the country and then a table to reference the city/postcode.
Comment #21
Alan D. CreditAttribution: Alan D. commentedGoing all the way back to the patch in #2, we are getting a function not found fatal error. ( version 3.0 ) A quick fix was to alter the menu callback to include "location.inc", or this could be added to the menu callback function. (Menu appears cleaner)
Comment #22
Alan D. CreditAttribution: Alan D. commentedI was getting too many issues with the 6.x-3.0 version, so I upgraded to the dev version, looking better :), and reapplied the patch without the .it cities (it is cleaner to review this way).
This is a great addition, but linking to states would be the next logical step, but adds a layer of complexity.
Comment #23
Cyberwolf CreditAttribution: Cyberwolf commentedSubscribing
Comment #24
jcolby1028 CreditAttribution: jcolby1028 commentedSubscribing
Comment #25
khan2ims CreditAttribution: khan2ims commentedThe patch is not working on my 6.x-3.1-rc1 installation.
Comment #26
Alan D. CreditAttribution: Alan D. commentedThe patch was against a recent development version in CVS. I do not know what happened to the 3.1 branch, but it is not being shown anymore. Try the older patch, no new functionality was added in #21 (removed .it city data to keep the patch cleaner), it was just an updated patch to match the new 6.x-3.0 dev code
Comment #27
PieterDCApplying the patch is not sufficient for it to work. You also need to provide a location_city_list_xx() for each country you provide. Take a look at the older patch, (in #2) Alan D. is talking about, to see how it's done.
@Alan: if you'd put the Italian cities in the zipcodes table, the patch could provide a general function getting all cities per country, instead of putting them in a hard-coded array in every country specific file, and thus eliminating the requirement of a location_city_list_xx() for each country. Or am I missing something? Just thinking.
Comment #28
Alan D. CreditAttribution: Alan D. commentedThis seemed like two issues - fix the bug & Italy data inclusion. Having one makes it easier to get the bug fix committed without having to wait for the feature request to get processed. I do not have the working knowledge of the module to comment any more sorry.
Comment #29
khan2ims CreditAttribution: khan2ims commentedHi,
Now the auto complete is showing up. But the location is not getting saved (although the form gets submitted) and hence location doen't show up on profile page.
Please check http://art.newearthmarketing.com/users/admin
Edit: I redid everything, and its working now :)
Comment #30
colanYou shouldn't have to add any "location_city_list_xx()" function. As stated previously, this is redundant information that already exists in the zipcodes table.
Comment #31
colanThis patch grabs city information from the zipcodes table.
Comment #32
hz_i3 CreditAttribution: hz_i3 commentedsubscribing
Comment #33
PieterDC@colan: good thinking!
Comment #34
YesCT CreditAttribution: YesCT commentedPowered by Dreditor.
Extra space at the end of the line.
My first time using Dreditor... not a functional review. :) That is still needed.
Comment #35
clashar CreditAttribution: clashar commentedsubscribe
Comment #36
timos CreditAttribution: timos commentedsubscribe
Comment #37
timos CreditAttribution: timos commented@colan
Sorry for this newbies' question, but on witch files i have to apply the patch.
I try on location.inc, location_autocomplte.js and location.module, but it worked only on the two first files and not on the location.module file (maybe because i use the 6.x-3.-dev)
An another question : is this patch independant from other patches (#2 and #22 posts) ?
Thanks
Timos
Comment #38
timos CreditAttribution: timos commented@colan
Well i apply your patch on the location.module file of a 6.x-3.0 version and it works correctly (make dif on location.module, location.inc and location_autocomplete.js).
So, after that, i tried it with the belgium cities (i dump the zipcode.be.mysql file in my database) and i could observe somes issues i report here to help you :
I had a location register in US : when i edited it and i select belgium in the country field, the city autocompletion was staying on the us
in firebug console the get url was location/autocomplete_city/us/.. and no location/autocomplete_city/be/..
So, i save my node with only country belgium, and when i edit again the form, autocompletoin works good with belgium cities and this address in firebug console :
location/autocomplete_city/be/..
Another issue :
I try after with france (no cities in database) and i don't know why but the autocompletion did on belgium cities (thought the address in firebug console was location/autocomplete_city/fr).
The bug didn't happen with US selected.
My english is worth, so i'm very sorry for that... and i'm not sure to be very clear so don't hesitate to ask me some precision
Cheers,
Tim
Comment #39
YesCT CreditAttribution: YesCT commented@timos don't worry about your english. You did a good review.
Sounds like this needs a new reroll against the latest version of dev. It might be possible if someone tried to make the changes by hand. Also try a google search for:
drupal how to create patch
and ths needs a fix so it notices when someone changes the country.
Also i don't remember if this is in there or not but this would need a setting in the configuration to turn on and off auto complete and it would need to default to off, so it would not break anyone's existing site.
Comment #40
colanI don't have a proper environment set up now to test this, and I never did. I just changed some code so that folks would start moving in a direction that uses zipcodes rather than doing it the old way. Sorry I can't help with testing right now.
The patch should work on its own, but, as mentioned above, will need to be rerolled.
Comment #41
khan2ims CreditAttribution: khan2ims commentedHi,
The auto complete is working on the forms now. Its great!
I am having a search form where I am exposing the city field. There it doesn't displays as auto complete field. What should I do to display this city field as auto complete on my search forms?
Thanks in advance.
Comment #42
juicytoo CreditAttribution: juicytoo commentedHi,
if this is working, can it be committed to a dev version.
There are so many patches available for location its hard to keep track of which ones apply.
In either case, for this to work, do we need to download the latest ver and then apply this patch?
Is this the general procedure for all patches?
Thanks.
Ed
Comment #43
YesCT CreditAttribution: YesCT commentedthis cannot be committed until it has a config option (and the configuration setting defaults to the current behavior, which is not to use the autocomplete). that is why the status is "needs work".
Also, I'm not sure as mentioned in #41, if the autocomplete for search is a problem that needs to be fixed in this issue/patch, or if that is a separate issue. What do you all think?
Ed, yes, in general try to apply the patch to dev (actually... it is probably best to assume the patch works with whatever version is mentioned in the issue (see the issue information, near the beginning of the issue page) for the version. :)
If you are running any patches against location, please try to find an issue that addresses it (probably the issue you got the patch from) and make sure that issue is moving forward, getting reviewed if it needs reviewed. Or getting worked on if it needs work. The goal is to get it to apply against the most recent dev, and get it reviewed by 1 or 2 people so that it can be marked RTBC (reviewed and tested by the community).
http://drupal.org/patch/apply
http://drupal.org/patch/create
http://drupal.org/node/156119 (on issue statuses)
... I could not find a good overview of "how do I get a patch committed" ... try http://drupal.org/patch/submit
Also, a summary posted so the maintainer can quickly read a recent commend that summaries the original problem, the changes the patch makes functionality wise, the changes to the code in general and any effects it might have.
Comment #44
edjay CreditAttribution: edjay commentedI have make a diff from the last 3.1
It's only my second patch so verify the file please.
Comment #45
YesCT CreditAttribution: YesCT commentedComment #46
vlooivlerke CreditAttribution: vlooivlerke commentedPatch #44 Worked for me.
Latest stable gmap, drupal, location 3.1 with #44 patch worked out of the box for country South Africa.
To make the module use your country on activation, I first installed the zipcodes table, then replaced all US country calls 'us' with 'za'
There is about 3 of them in the location.module file.
Then activate the module as usual.
Here is a question.
The autocompleate shows the city name followed by a comma then its state/provance (Cape Town, WC)
Now if you fill in the province it outputs
(Cape Town, WC, WC) this does not look nice.
Thanks for the patch edjay
Comment #47
YesCT CreditAttribution: YesCT commentedI think for this to be committed, it needs to have a setting in the UI, so people dont have to modify the code (to get it to work for non US countries) and also, the thing with the extra comma and province needs to be sorted out.
Comment #48
vlooivlerke CreditAttribution: vlooivlerke commentedThe extra comma, is a blessing!
I have been playing with the new input. If I enable geo-coding for South Africa (google) and only enable the Street and City fields in location, The full string sent to google contains
street, city, state/province
This is enough info for google to place the marker exact, so no need for the extra state/province field (that also auto-complete)
Makes sense, coz a town will only be in one state/province
If it could include the postal code too then a user can make sure, he gets to postal code level if he does not want to put his street address.
I think this is a valuable breakthrough. This enables you to only input 2 fields, where one auto-completes, so very simple to submit location.
P.S, I changed my State/Province short codes to the full names to guarantee google geo-coding to be exact. (simple find and replace function in Table)
Comment #49
zualas CreditAttribution: zualas commentedSorry but I'm not getting anything from the patch. I see the autocomplete widget, but it does not return anything. Here are the steps I've done
1) Applied the patch to v3.1
2) Loaded the US zipcodes into the database
3) Enabled the Location CCK widget with Country, Province and City fields
4) When I enter the country, the province suggestions are given, but the ones for the city aren't.
Am I missing something?
Thanks!
Comment #50
vlooivlerke CreditAttribution: vlooivlerke commentedTry this.
Uninstall the location module, go to the zipcodes table to find it empty.
Then load us zipcodes.
Now enable module. Go to any content type and test auto-complete of city.
Make sure your patch is correct. I did mine by hand.
Comment #51
zualas CreditAttribution: zualas commentedI tried to do as you said, but I'm getting this javascript error all the time. Tried both 3.1 and dev version, applied the patch manually.
Comment #52
Berliner-dupe CreditAttribution: Berliner-dupe commentedHi,
the patch from #31 http://drupal.org/node/404830#comment-2912458 works fine for me - but - there is a little problem.
When i set the first letters from a city - then the autocomplete-field show me the City-Names AND behind the "State-Names"
Example: Berlin,BE
But - I dont need the State-Names - i need the country-Name.
Example: Berlin, DE or New York, US
I changed in Patch ....
SELECT DISTINCT CONCAT(city, ',', state) AS city FROM {zipcodes}
to
SELECT DISTINCT CONCAT(city, ',', country) AS city FROM {zipcodes}
but it have no effect. Cache is cleared.
Has anyone an idea?
Sorry for my bad english.
Thank you and Regards
Matthias
Comment #53
BenjaminG CreditAttribution: BenjaminG commentedCould this work for postcodes too?
I have a defined list of postcodes I want people to be able to select from when entering the location information. That defined list of postcodes is in the zipcode table. It would be really good if, when entering the postcode information, it selected the postcode from the zipcode table and autofilled the other information. That way I could use the location module for everything!
Comment #54
shopdogg CreditAttribution: shopdogg commentedsubscribing
Comment #55
SebastienT CreditAttribution: SebastienT commentedHi @Berliner,
I have the exact same problem...
Have you figured this out yet?
Regards
Comment #56
Berliner-dupe CreditAttribution: Berliner-dupe commented@SebastienT
No - i dont found an answer for this problem.
I dont know how can i fix this.
Comment #57
bryancasler CreditAttribution: bryancasler commentedsubscribe
Comment #58
marcoBauli CreditAttribution: marcoBauli commentedhumm.. autocomplete seems to work out of the box but on Location settings pages only (backend), not on node edit forms.
patch #31 didn't help..anyone knows how to make this work with latest version of Location? thx
Comment #59
ccheu CreditAttribution: ccheu commentedsubscribe
Comment #60
petr.gorodechnyj CreditAttribution: petr.gorodechnyj commentedI used the patch #44: http://drupal.org/node/404830#comment-3180128.
Had a problem with some parts of location plugins (node_location and user_location). They seem not to be able to load all necessary entries from database if autocomplete path ends with country id. I used the "Array" instead and it solved the problem.
The fragment of location.module:
Oh, yeah, I replaced countries before from 'us' to 'ru', but this didn't change a thing.
P.S.> Well, the problem was somewhere else, probably, 'cause after I had 'white screen of death' on front page, I nearly reinstalled all the site. And after that I got 'location/autocomplete_city/Array' no working, so I rolled back to $country. But probably it will be useful for someone.
Comment #61
bryancasler CreditAttribution: bryancasler commentedsubscribe
Comment #62
prabhakarsun CreditAttribution: prabhakarsun commentedIs this available for location CCK?
Comment #63
prabhakarsun CreditAttribution: prabhakarsun commentedI wanted to have select box for states & autocomplete for cities. But #44 & #100 in http://drupal.org/node/364287 are not working together.
Comment #64
prabhakarsun CreditAttribution: prabhakarsun commentedoops, it was my fault. Didn't clear cache.
Comment #65
vlooivlerke CreditAttribution: vlooivlerke commented@#52 To fix "City, STATE" dispay in autocomplete to "City" only
Uninstall location.module and reinstall to take effect or make this change before you install this module.
Some problems with the cache or something..
Comment #66
Anonymous (not verified) CreditAttribution: Anonymous commented+1
Comment #67
chrislabeard CreditAttribution: chrislabeard commentedI've been trying to get this to work I patched it against 3.1, It tries to do something but it returns no results. I've imported all of the zipcodes.us into my db.
did I miss something or is it supposed to be with the dev version?
Comment #68
laraz CreditAttribution: laraz commentedsubscribe
Comment #69
leenwebb CreditAttribution: leenwebb commentedAny progress on this? The patch in #44 applies just fine against 6x-3.1 (July 2010) but the auto-complete doesn't work; the field cycles and looks like it's searching but not finding any matches. I've cleared caches, reloaded the zip code table, un-and-re-installed module, etc. Has anyone been able to get this to work with US cities/states?
Comment #70
vlooivlerke CreditAttribution: vlooivlerke commentedHere is my version, also has some auto complete fixes for state/province
From my production site.
Install location, then fill empty zip codes table, then only install location node module.
enjoy.
Comment #71
lyleadmin CreditAttribution: lyleadmin commentedsubscribe
Comment #72
ankur CreditAttribution: ankur commentedAutocompleting for cities is the kind of bloat I'd like to keep out of this already gargantuan, monolithic module. I'd encourage anyone that is seeking this functionality to implement it as a plugin or as a custom one-off in your project.
Comment #73
Summit CreditAttribution: Summit commentedHi,
I understand what you are saying, but it would be great if people still post there plugin, custom one-off so other can benefit from it.
Would love a google maps sort of integration of countries, cities etc..
Thanks still for this great module!
Greetings, Martijn
Comment #74
pragna CreditAttribution: pragna commented#44 patch is working for me, but it is not finding any city for any province of any country.
Please help me how to add all cities of all country.
Comment #75
pragna CreditAttribution: pragna commentedComment #76
Alan D. CreditAttribution: Alan D. commented@pragna Ankur is a maintainer of the module, so has the right to close a feature request. Also no feature request should ever be considered critical!
Comment #77
jim005 CreditAttribution: jim005 commentedsubscribe
Comment #78
colan@websenso_com: There is no need for subscribe comments any more. Simply click on the "Follow" button at the top of the issue.
Comment #79
drupalina CreditAttribution: drupalina commentedI'm reopening this issue to see if anyone has come up with a plugin for 7x.
I have manually implemented the patch in #44 (in 7x the names of those functions are all the same, so it was easy to find) and changed default country from 'us' to 'au' (which is among the databases). The autocomplete toggle gets activated, but then the browser spits out an AJAX error, so basically it doesn't work.
Has anyone found a solution for 7x version of Location?
I'm also looking for a similar autocomplete functionality for the Location field in exposed proximity search.
PS: I understand that autocomple for Cities and exposed filters is a BIG task, but here is a question: how often do you go to a decent website and not see the location field be autocompleted? Never! In this day and age the end-users expect it to work.
Comment #80
nstahl CreditAttribution: nstahl commentedsubscribe
Comment #81
podarokComment #85
podaroknothing to review yet
Comment #86
dancor CreditAttribution: dancor commentedany news?
Comment #87
Agiss CreditAttribution: Agiss commentedHi guys,
We have started working on a patch for Cities autocomplete and Postal Code autocomplete for Location version 7.x-3.7.
Please have a look at https://www.drupal.org/node/2712081#comment-11129657
Hope this helps
Cheers
Agis