Hi
I see a lot of issues in the queue along the lines 'there is a new province in country xx, please update your module' etc, it would be nice if location module gave other modules a chance to change the province values/lists as this would alleviate the need for you guys to patch the module for every change to provinces etc around the world.
I propose that location_get_provinces exposes a hook 'hook_location_provinces_alter' allowing other modules to alter the provinces before they hit the cache.
Also this would allow other modules to extend the location entry widget - eg to reuse the province field for an alternate reason without needing to recreate any of the database code, validation, processing etc, - eg a simple hook_form_alter to attach an #after_build to the location element would allow changing of the province/state title and then an implementation of hook_location_provinces_alter would allow for a new LOV. And all of this without hacking the module. Example use case - a site that is only targeting one state/province but is wishing to collect a 'region' associated with the location, this change would allow the province field to be reused for just this purpose.
Anyway, I've attached a patch that does just this and hope you consider my request (and yes it is just a one line change).
The drupal_alter is called with the $province array and not the $province[$country] array so the hook implementatons can test the country code and respond accordingly.
Thanks
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | location-provinces_alter-853810-15.patch | 1.58 KB | sanchiz |
| #9 | location-provinces_alter-853810-9.patch | 1.52 KB | Anonymous (not verified) |
| #8 | location-provinces_alter-853810-8.patch | 1.49 KB | Anonymous (not verified) |
| #4 | location-provinces_alter-853810-4.patch | 899 bytes | rooby |
| #1 | location-province-alter.patch | 673 bytes | larowlan |
Comments
Comment #1
larowlanComment #2
yesct commentedI think we need some committer feedback on this direction
Comment #3
tobiasbComment #4
rooby commentedI don't think this should be used for:
because we need the location module's provinces to remain as up to date as possible.
That said I know the issue queue review process isn't always as fast as we would like it to be so this would be useful for the interim period until patches are committed.
It would also be useful for custom cases like you mentioned.
I don't think it is the best idea to pass the whole provinces array in though as it is called per country so you only want to send that country's provinces.
Here is a version that passes a second $country parameter to use to determine the country.
Any objections to this approach over the patch in #1?
And for reference, here is an example implementation of the alter hook in case anyone wonders how to use it:
Comment #5
lpedretti commentedSeems reasonable to me, it is also a problem of the 7.x branch.
It's not only the updates, but the fact that anyone may need to use custom naming. For example, i use a webservice from a geo database with hierarchical continent/country/region/state/city and even districts precision, and they have their own code ids. I really think that being able to hook that information to replace the default one is a BIG improvement that would allow for a lot of important customizations with just a few line of code.
Best regards
Comment #6
podarokall feature requests should be rolled against latest 7.x-3.x-dev and after commit can be backported to 6.x branch
Comment #8
Anonymous (not verified) commentedSince the #4 patch failed i've created a new one. Hopefully this one succeeds..
It invokes 2 hooks:
Comment #9
Anonymous (not verified) commentedhmm. replaced the ternary operator on my previous patch,
Comment #11
grisendo commented9: location-provinces_alter-853810-9.patch queued for re-testing.
Comment #12
grisendo commented#9 works OK for me.
Previous test fail looks like was due to Google Maps service outage.
Comment #13
podarok9: location-provinces_alter-853810-9.patch queued for re-testing.
Comment #15
sanchiz commentedUpdated patch regarding new updates in the dev branch. Also added $lang_code to the cache key, because it has been lost in the previous patch.
Comment #17
podarok