Custom display suite fields in Drupal 8
One of the most useful modules in Drupal is display suite. Something I constantly use, especially for creating custom display fields.
What’s a custom display field?
It’s purely a field for rendering specific content on the display. No field api work, we just want to get some information related to the node and display it in a display suite template
Why would I need to use a custom display field?
The short answer is you’ll always need to do something like override a node or field template, and usually that’s enough. But sometimes you need a bit more, that’s where display suite fields come in. Let’s say for example we wanted to display a nodes published date and the author like this:
28 November 2016 by FoxMulder
We could display the fields next to each other, and let the themer handle it, but that’s not that nice. We could also just do this in the node template, but what if I want this on multiple view modes? I would have to override the template for each one. Plus, with this configuration being in code, it’s a bit nicer to handle.
Here is an example custom module to show you a very basic field showing our date and author.