Problem/Motivation
Allow different icons between views rows. Differentiated by some field in the view, eg. node type.
Proposed resolution
Enable twig with fields as twig variables on the icon setting field to allow using the values from fields to define the url of the icons.
User interface changes
Icon field setting on the view will be switched from textfield to textarea to account for the longer twig expressions. And icon field setting can no longer be validate as a valid path since we can not evaluate the twig expression without values from a row.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | leaflet-views_icon_setting-2803299-9.patch | 7.06 KB | itamair |
Comments
Comment #2
ooystein commentedHere is a patch that enables twig on the icon fields and adds the fields as twig variables.
We should consider adding context variables to the twig variables if this is requested by anyone.
PS. This does not work when twig debugging is enabled as it includes html comments to the variables
Comment #3
netsliverNew patch for the latest dev version
Comment #4
joumWorks like a charm! Good job!
I'm using core 8.5.6 under PHP 7.2.7.
If this ends up entering the Leaflet module's core, some info on how to style the marker in depth would be nice, too.
Would it be hard to also add a className to the marker?
Comment #5
itamair commentedtnx @netsliver ... going to review this asap, also with @joum requests ... and eventually amend or commit to dev
Comment #6
afschIn Drupal 8.5.6 under PHP 7.1, I got an error trying to load the Manage Display (default display). Here I added the same patch in #3 with an extra condition. This issue is related to Field Formatter.
Anyway this solution works amazing, Thanks.
Comment #7
afschComment #8
shortspoken commentedWorks as expected. Thanks everyone! :)
Comment #9
itamair commentedThanks dudes for this contribution.
I reviewed more carefully, and some important amends were needed, in the last #7 patch both on coding standards and correct OOP implementations, and also because you didn't considered that all the changes applied into the LeafletSettingsElementsTrait would have affected (and messed up) the LeafletDefaultFormatter ... in which the Views Fields Tokens implementation wouldn't have applied/worked.
Here it is a final patch that works and that is going to be committed into dev and last new module release.
Comment #11
itamair commentedComment #12
itamair commentedIt would be nice to extend this functionality into the LeafletDefaultFormatter too ...