Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
There is already a hook_proximity_views_handlers present.
I added a 'module' and a 'path' argument to the proximity handler definition.
This way a module can define plugins by implementing hook_proximity_views_handlers
Attached you can find a patch to make this possible and a small module that defines a custom proximity plugin.
With the module you can choose a taxonomy library with a geofield and use the terms of this library as a select option.
This is handy when you want to limit the users location options.
Comment | File | Size | Author |
---|---|---|---|
#13 | geofield.tgz | 55.64 KB | RdeBoer |
#12 | allow-other-modules-to-define-proximity-plugins-2134777-12.patch | 8.86 KB | RdeBoer |
#8 | proximity-ajax-error.png | 28.43 KB | vlooivlerke |
taxonomy_geo.tar_.gz | 1.71 KB | stijn.blomme | |
geofield_add_path_and_module_arguments.patch | 2.33 KB | stijn.blomme | |
Comments
Comment #1
bneil CreditAttribution: bneil commentedComment #2
RdeBoerGreat patch and great little module!
The patch is simple and would further improve Geofield's already great architecture.
See the discussion at https://drupal.org/comment/8528069#comment-8528069
Rik
Comment #3
mglamanI don't have a chance to reroll patch at the moment, but you're calling $plugins:
module_load_include('inc', $plugins[$plugin]['module'], $plugins[$plugin]['path']. $handlers[$plugin]['class']);
when it should be $handlers, I believe
module_load_include('inc', $handlers[$plugin]['module'], $handlers[$plugin]['path']. $handlers[$plugin]['class']);
Comment #4
RdeBoerAgree with mglaman in #3. Typo. Here's a new patch.
EDIT try the patch from #12.
Stijn.blomme's idea for the original patch is simple, elegant, low-risk, yet hugely important in allowing other modules to add proximity plugins to Geofield, without Geofield having to know about the modules.
So it avoids Geofield maintainers having to put ugly
if (module_exists('someonesmodule')) { ... .}
every time someone has convinced them of a useful plugin.For starters, his idea allows me to redo https://drupal.org/comment/8528069 inside ip_geoloc (where it belongs), rather than making it as part of Geofield.
Stijn.blomme's patch makes for a much cleaner and more maintainable Geofield architecture.
Please Brandonian, apply the patch from #12, so we can all build on it in our own modules.
Rik
Comment #5
RdeBoerComment #6
RdeBoerSorry typo in my patch. New patch attached.
Comment #7
RdeBoerThis patch adds some robustness to the previous one, avoiding WSODs in case typos were made in the plugin name or file spec.
This patch, if chosen, needs to be applied instead of the one in the previous comment, NOT in addition too.
Comment #8
vlooivlerke CreditAttribution: vlooivlerke commentedHi, Rik
when applying patch against 7.x-2.x-dev the top part does not apply.
giving me the following ajax error when trying to add the proximity filter
I manually patch it, but then noticed that it is a bit different than what the patch sugests
the
part is not in the patch
Comment #9
RdeBoerRe #8:
The bit you tried to change manually is near line 141. It is very similar to the lines near 107, which is what the patch changes.
However the lines near 141 do, on second observation, need a similar treatment for the case where old Views are converted to the new style.
I'll produce a new patch soon.
Rik
Comment #10
pixelsweatshop CreditAttribution: pixelsweatshop commentedCan confirm #8. Any chance you have that updated patch, Rik? I tried to give it a go but it my attempt was messy.
Comment #11
vlooivlerke CreditAttribution: vlooivlerke commentedPlay with this version of Rik's geofield
its got some superhero stuff build in, and works
Comment #12
RdeBoerReran the patch. Hopefully this one applies without issues.
The patch is against Geofield branch 7.x-2.x
Comment #13
RdeBoerHere's Geofield 7.x-2.x with the above patch from #12 attached as a read-to-install module.
Comment #15
Brandonian CreditAttribution: Brandonian commentedThanks for the patch, @RdeBoer. Committed to 7.x-2.x
https://www.drupal.org/commitlog/commit/19248/8e32d16fdb69569ec7c91a4c7f...