Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough
Jul 23 2020
Jul 23

The Entity Extra Field module for Drupal 8 lets site builders attach blocks, views, token driven content, and entity operation links as orderable pseudo-fields to any entity’s edit form or its displays. After installing the module any user with the Administer entity extra field permission can easily configure node attributes like author or publish date as orderable fields — as well as create block fields, views fields, operation link fields (like Edit and View) or a host of other custom entity fields with a simple point and click interface.

Entity Extra Field is essentially an easy-to-use UI for configuring Drupal’s pseudo-field components that are defined and exposed through hook_entity_extra_field_info(). It puts the power and flexibility of pseudo-field elements into the hands of site builders, delivering a wide variety of new field configuration possibilities without dipping into custom code.

A quickstart example: node properties as fields

Here’s a quick example of configuring node properties as fields (or technically, pseudo-fields). Let’s say you’d like your site’s Article content type to display the author at the bottom of the post, instead of the standard display just beneath the title. With the Entity Extra Field module, you’ll be done in two minutes. First make sure you have the Token module installed on your site, then download the Entity Extra Field module via composer using:

composer require drupal/entity_extra_field

You can read about using composer to download modules & dependencies on Drupal.org. With Entity Extra Field installed, you’re ready to get started.

An article node with the author and publication date displayed beneath the article title Right out of the box, an Article node type displays the authoring information just beneath the node title.
  1. Enable both the Entity Extra Field and Entity Extra Field UI modules via drush en entity_extra_field and drush en entity_extra_field_ui or the old-fashioned way on the Extend page at /admin/modules
  2. Navigate to Content types administration at /admin/structure/types and click the Manage fields button next to Article
  3. Click on the new tab, Manage extra fields, to add your pseudo-field
  4. Click the Add extra field button at the top of the page, then fill out the form to define your new "Node author" field:
    • Field Name: Node author
    • Display Type: View
    • Description: The node’s author
    • Field type: Token
    • Field type configuration: Text field
    • Token value: Another great article by [node:author] (note that you can browse through about a billion other useful tokens via Browse available tokens)
  5. Use the Field Type Conditions options at the bottom of the page to enable your new pseudo-field for just the Article content type
  6. Finally, after saving your new "Node author" pseudo-field, head to the Manage Display tab of your Article content type and order your new field — in our case, just below the body

To complete our task, we’ll probably also want to disable Display author and date information in the Display Settings section of the Article content type Edit tab. Voila! Your node author is now a field.

An article node with the node author displayed below the body text using the Entity Extra Field module. After a few quick configuration steps, an Article node displays the custom author pseudo-field just below the body.

You could easily repeat the above steps to establish a new "Post date" field — also orderable just like the new "Node author" field — and place that beneath the title or wherever you please. It’s also worth noting that the Field Type Conditions options (step 5 above) can add a whole layer of flexibility to when and how your pseudo-fields appear.

Entity Extra Field: Taking it to the next level

Creating token fields is just the beginning. With the Entity Extra Field module you can attach any block, view (with contextual arguments), token, formatted textarea with tokens, or — thanks to recent contributions from geek-merlin — entity operation links like Edit and View to any entity type edit form or display. The result isn’t limited to super configurable entity displays — there’s a whole world of possibilities using views with arguments or custom blocks as pseudo-fields.

Example graph data rendered with the help of Entity Extra Field shows uninsured statistics by race / ethnicity. An Entity Extra Field implementation for The Commonwealth Fund's Health System Data Center uses a block pseudo-field to place dynamically rendered React charts on the node page — driven by node field data.

I originally built this module, for example, to display dynamically rendered React charts as a node pseudo-field, where the data represented in the chart is driven by the values of various fields from the node context definition. The result is an easy-to-edit node form where content managers can add or edit the statistical data that drives the charts via normal node fields — and an orderable, configurable pseudo-field on the node display that renders the chart just like a regular field without complex configurations or poking around in code.

What else can you do with the Entity Extra Field module? You decide. And if you come up with anything you’d like to share, please let me know!

Jul 16 2020
Jul 16

The Notification Message module for Drupal 8 lets content editors quickly and easily publish configurable notifications. It can create site-wide notifications, conditional alerts, or other site messages — all using a consolidated UI that doesn’t require editors to stitch together functionality with complex combinations of core and contributed modules.

Have your organization’s hours of operation changed for the holiday? Is a specific product on backorder? Has a service area been affected by a storm system? No matter who needs to read it, what it needs to say, or when it needs to be automatically published and unpublished, Notification Message makes crafting messages to users simple.

The Nashville Public Library website with a prominent notification banner deployed with the Notification Message Drupal 8 module. Nashville Public Library uses the Notification Message module for Drupal 8 to deploy notification messaging specific to distinct audience segments in a bright, clear yellow banner.

I built the Notification Message module to help Nashville Public Library broadcast site-wide or contextual messages to their customers via time-boxed notification banners. Their previous system, built on Drupal 7, used separate content types for each variety of notification, and relied on configurations completed elsewhere in the site (blocks, contexts, scheduled or manual publishing) to function properly. Notification Message provides a clean, natural editorial experience and bakes in a lot of configuration options.


Notification Message un-clutters the content management experience and provides simple but powerful tools for editors. Notifications are:

  • Published and unpublished automatically within a specified date and time range
  • Built using custom entities to maintain separation from the standard content publishing experience
  • Linked in the Content Menu right out of the box to slide naturally into the content admin UI
  • Highly configurable via conditions to show up when, how and to who you want
  • Extensible far beyond basic site-wide banner messages using custom fields, custom templates and custom conditions
  • Complete with granular permissions for both administering custom notification message types and managing notification content

Quickstart Guide

Setting up Notification Message — and your first notification — is simple. First download the Notification Message module using the composer workflow: composer require drupal/notification_message

If you need help with composer, check out using composer to download contributed modules on Drupal.org. Once the Notification Message module is available in your project, you’re ready to get started.

  1. Enable Notification Message via drush en notification_message or directly from the Extend page at /admin/modules
  2. Navigate to the Content page at /admin/content, then to the new navigation item Notification message
  3. Click Add notification message, choose the Global type (for now) and complete the entity edit form, making sure to select the appropriate theme under Notification Conditions / Current Theme, and a date & time range that includes right now under Notification Options / Message Publish
  4. After saving your notification, head to the Block layout page at /admin/structure/block and place the Notification messages block (via the Place block button) in the appropriate region

Mission accomplished! Now you’ll see your global notification in the region you assigned as long as the current date & time are within the date range you indicated in the Message Publish section of the entity edit form. You can create new notification message types from the Notification Message types page at /admin/structure/notification-message-types that can respond to diverse conditions such as Page URL, node attributes and user attributes — or any other conditions defined by your site — and can include custom fields and custom display configurations.

The Human Rights Watch website featuring a takeover lightbox delivered via the Notifications Message module for Drupal 8. Human Rights Watch used a fielded and conditioned implementation of the Notifications Message module earlier in 2020 to deliver rich form content in a Lightbox takeover to drive a donation campaign.

Custom templates for your custom notification types can override or extend the included notification-message.html.twig and notification-messages.html.twig templates for a variety of presentations — from the standard site-wide notification banner to whatever you can imagine.

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web