Short story
Leaflet *does* reconoze entities in ordinary views, but *not* in Search API views.
Original report
We found an alternative solution for this problem.
Problem / Situation
In Views Leaflet Formatter Settings we are used to select a field or < node entity > for the popup.
However, using a Search Index based view < node entity > does not exist in current 1.0-beta3 release.
And the rendered entity from the index is unusable as field.
Proposed Solution
Support < node entity > for Search API based views.
Alternative Solution
Apply the patch from Allow rendering an entity viewmode when using fields in views (currently #20 is working fine, but does not have tests yet)
Add a field Rendered Item to your view, select it for the Leaflet popup.
Comments
Comment #2
hannessComment #3
hannessComment #4
geek-merlinTo make this better reviewable, i port a part of the patch from #2995576: [Performance!] Implement Ajax-lazyloaded Markers to here.
Patch flying in.
Comment #5
geek-merlinComment #6
geek-merlinNote that this simple patch only adds a new code path for search api style rows, so that it soes not interfere with the legacy code path and we get low regression risk.
Comment #7
geek-merlinLooks like some code ran away and we need to recognize entity type in ::init().
Comment #8
geek-merlinWith some fixes.
Comment #9
geek-merlinTested and works like a charm.
Comment #10
itamair commentedthanks ... @axel.rutz, will review this asap.
Just a little further feedback.
We had a quite similar issue on the Geofield Map module, that was solved (is seems) with this simpler patch:
https://www.drupal.org/project/geofield_map/issues/2994026#comment-12736192
Your patch looks more solid, BUT wouldn't be enough just this check here too?
$entity = $result->_entity ?: $result->_object->getValue();I am minding to replicate this solution from you also in the Geofield Map module otherwise ...
Comment #11
geek-merlinGood point. I had chosen to be more verbose here for reasons...:
* I'm being a bit paranoid: if someone else adds an _object to that array (we have so many modules...) this does not break.
* On an IDE like PHPStorm (use it, man! Proprietary but free or FROSS maintainers), with a typehint like this we get free introspection (it checks if that method is called with correct parameters, click on the call and see the method, ...), which is good DX.
(PS: phpstorm als lets you "rename this variable / method" without omissions ;-)
Comment #12
itamair commentedGoood. Well noted. Going to commit all this asap.
PS: Sure PhpStorm all life (so far ... ;-))
Comment #13
itamair commented@ axel.rutz your patch, but slightly improved with better php/drupal cs variable naming and use of already injected $this->moduleHandler service.
Please confirm that all this is ready for commit ...
Comment #14
geek-merlinYes that makes nicer code! Tested this together with #2995576-7: [Performance!] Implement Ajax-lazyloaded Markers and still works as expected.
Comment #16
itamair commented