Timeline for How to use custom class methods in the .theme preprocess functions?
Current License: CC BY-SA 4.0
6 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jan 27, 2020 at 9:32 | comment | added | svetlio | because it is interesting topic here is another approach - to use extra field - this will keep the original field for further usage available alongside the new field - api.drupal.org/api/drupal/… | |
Jan 21, 2020 at 16:54 | comment | added | Kojo |
Great ! Unfortunately I don't have enough time now to refactor the code again for this feature, since the implemented solution with Drupal::service is clean, but I'll keep your answer as a reference for later :-)
|
|
Jan 21, 2020 at 10:53 | comment | added | svetlio | $item->getEntity() will give you whole entity so you can use any fields value to prepare your output, if this make sense | |
Jan 21, 2020 at 9:20 | comment | added | Kojo | Sounds good, thanks ! Not sure I could achieve it this way though, because this was indeed a simplified example code : the real formatter treatment relies on the values of 2 fields. | |
Jan 20, 2020 at 20:49 | comment | added | Kevin | This is probably the way to do it. A field formatter would make it DRY, and usable outside of Views or in other views without repeating code. | |
Jan 20, 2020 at 19:58 | history | answered | svetlio | CC BY-SA 4.0 |