DrupalEasy Quicktips are short, focused posts intended to accomplish a very specific goal. Quicktips are exclusively available first via our @drupaleasy Twitter account.

Using Drupal's Linked Field module to output fields as links in view modes

With Drupal 8, the use of view modes (both default and custom) is gaining momentum. This is especially true because of their ability to be easily utilized by Views. Rather than specifying a list of fields with all the required configuration in a View configuration, many site-builders are finding it much easier to define a set of view modes for their entities, have them themed once, then re-used throughout the site - including as part of a View's output via the "Show: Content" option in a View's "Format" configuration. 

Demystifying Drupal 8's breakpoints.yml file

While working through a couple of Drupal 8 projects involving a custom theme, I've been curious about the themename.breakpoints.yml file. I've dutifully updated it with the proper breakpoint values, but I've been a bit mystified with its actual purpose. There's nothing in either of the base themes I've used (Neato and Bootstrap) that actually appears to utilize the data in the breakpoints.yml files.

Checking for the existence of a field value in Twig

Twig syntax is new for most Drupalists, and learning how to check for the existence of a field value is a valuble skill for anyone building a Drupal 8 theme. For example, consider the case where there is an optional text field called "Photo caption" on a content type. If the content author populates the "Photo caption" field, then it should be output as follows:

<figcaption>{{ content.field_photo_caption }}</figcaption>

Enabling "development mode" on a local Drupal 8 site

Drupal 8 includes some great debugging tools built-in, but it isn't always super-obvious how to access them. Luckily, the Drupal Console "site:mode" command helps out quite a bit, but it also requires the site to be configured properly before it can be successfully used. I find that having access to the Twig template name suggestions is invaluable when theming a Drupal 8 site:

Display modes, view modes, form modes - what's the difference?

With "Display modes" now a first-class citizen in Drupal 8, there is some lingering confusion about the various "modes" in the Drupal eco-system. In previous versions of Drupal, it could be argued that "display modes" and "view modes" were the same thing. Now that Drupal 8 is available, we should make an effort to be more precise in our definitions of these terms. 

In short, both "view modes" and "form modes" are types of "display modes":

Drupal 8 "Mismatched entity and/or field definitions"

Updating modules in Drupal 8 is similar to updating modules in Drupal 7 - the drush pm-update (drush up) command still works, but there's a new "gotcha" that you need to look out for when updating modules that work with entities. 

Sometimes, after updating modules that interact with entities, you'll see a "Entity/field definitions: Mismatched entity and/or field definitions" error on your site's status report (admin/reports/status). 

Contact + Contact Storage (contrib) Module as a Drupal 8 Webform/Entityform Replacement

Looking to migrate your Drupal 6 or 7 site to Drupal 8 but can't do it yet because your site it too reliant on the Webform (or Entityform) module? There's actually very elegant solution that is ready to go today. The core Drupal 8 "Contact" module is now a fully-fledged fieldable entity - meaning you can create various "contact form" types with different sets of fields. Like Entityform, you can use any field types provided by Drupal core as well as contributed modules.

Drupal 8 paths inconsistencies

While Drupal 8 has plenty of things to be excited about, there are a few "gotchas" that site-builders need to be aware of as they build out sites. I found the first thing that I had trouble with was the way that Drupal 8 isn't very consistent (yet?) with the way it handles paths. In Drupal 7 and before, anytime you needed to enter a path, it (almost?) never started with a leading "/". For example, need to add an new alias for a node? You would enter "my-new-node", not "/my-new-node".