Submitted by Andrew on Wed, 07/19/2017 - 07:53

VIM

Re-read through Janus page and picked up a few tips:
https://github.com/carlhuda/janus
I've been wondering how to comment and indent code.

 

Drupal

I have been trying pretty hard to write a field formatter in Drupal. I can scaffold a Field Formatter plugin with Composer, but found it was a little easier to extend an existing plugin (found at /core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter). I chose IntegerFormat since I'm really just adding to it but otherwise like the formatting options.

Read the source code of FormatterInterface to see what the functions are you can override: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Field%21…

There are 3 functions related to the field display:

prepareView(): Allows formatters to load information for field values being displayed.
view(): Builds a renderable array for a fully themed field.
viewElements(): Builds a renderable array for a field value.

 

Render API

How do you use a render element?

Is the Field theme implemented with a render element?

Subject