Notification Message Module for Drupal 8
Notification Message Module for Drupal 8
Travis Tomka
Thu, 07/16/2020 - 10:15
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.
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.
Features
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 <span style="color: #b1b100;">require</span> drupal<span style="color: #339933;">/</span>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.
- Enable Notification Message via
drush en notification_message
or directly from the Extend page at<span style="color: #339933;">/</span>admin<span style="color: #339933;">/</span>modules
- Navigate to the Content page at
<span style="color: #339933;">/</span>admin<span style="color: #339933;">/</span>content
, then to the new navigation item Notification message - 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
- After saving your notification, head to the Block layout page at
<span style="color: #339933;">/</span>admin<span style="color: #339933;">/</span>structure<span style="color: #339933;">/</span>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 <span style="color: #339933;">/</span>admin<span style="color: #339933;">/</span>structure<span style="color: #339933;">/</span>notification<span style="color: #339933;">-</span>message<span style="color: #339933;">-</span>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.
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<span style="color: #339933;">-</span>message<span style="color: #339933;">.</span>html<span style="color: #339933;">.</span>twig
and notification<span style="color: #339933;">-</span>messages<span style="color: #339933;">.</span>html<span style="color: #339933;">.</span>twig
templates for a variety of presentations — from the standard site-wide notification banner to whatever you can imagine.