- 🇩🇰Denmark ressa Copenhagen
Just confirming that you still need to replace the "less than"
<
and "bigger than">
characters with HTML entities<
and>
in version 2.=
by itself seems to work as is.This doesn't work:
[node:field_map_position:latlon]<10km
This works:[node:field_map_position:latlon]<10km
I spent a lot of time trying to get #3149688: Geofield Proximity Filter from Node/Entity being viewed (guidelines) → working, and thanks for sharing the tip in #3139155-15: Drupal 9 Deprecated Code Report → @rafaticarte, it really helped me :)
- 🇩🇰Denmark ressa Copenhagen
Another tip: It seems like you can't test a block in the view by entering an argument, like the node id here:
Preview
Auto preview
Preview with contextual filters:
[ ]
Separate contextual filter values with a "/". For example, 40/12/10.You have to place the block and test it, actually placed in the context, i.e. on a node page.
- 🇪🇸Spain rafaticarte
Hi,
I use PHP code in contextual filter:
if (isset($entity['node'])) { $geofield = $entity['node']->field_activity_coordinates->getValue(); if (isset($geofield[0])) { return $geofield[0]['lat'] . ',' . $geofield[0]['lon'] . '<10km'; } }
I hope this can help you.
- 🇩🇰Denmark ressa Copenhagen
Thanks! The method in #9 works well, with this method:
Contextual filters >
Content: Map Proximity (field_map_position) (Default: Token) >
When the filter value is NOT available >
Provide default value >
Token >
... and then enter the string:[node:field_map_position:latlon]<10km
How would someone use the code you shared, and what would be the benefits over using the Views Argument Token solution outlined above?