2

I have several Drupal installations and I want somehow, to send a message that would be displayed in all of them at the same time, in a block for example. The scenario could be that the server will be down for maintenance, so I want to show a message on the admin section alerting this.

My first thought is trying to use something related with RSS Feeds, but if anyone has experienced the same situation any feedback will be appreciated

3
  • See this: drupal.stackexchange.com/a/22214/16495 – Mołot Oct 29 '14 at 12:48
  • tx @Mołot, that script is to perform tasks on multiple Drupal instances at once. What I want is to implement an alerting/messaging system in these instances before performing these tasks – luciano_s Oct 29 '14 at 12:52
  • So just add a little module to each site. Implement a drush command to set up message, and you are done. – Mołot Oct 29 '14 at 12:53
1

There are a number of ways to accomplish this, but I wouldn't recommend using Feeds for system wide alerts because of issues with the way Feeds locally caches the source RSS based on how often or infrequently it changes. This also requires maintaining redundant content types, views, and nodes across several sites. While this could be done with a Feature, there are much simpler ways to do this.

One extremely simple option is to configure each site to with a block that embeds an iframe from a centralized messaging site that isn't even running Drupal. Update the HTML of the message and it will be shown everywhere. When you are done, update the HTML to no longer display the message. Of course this will require a layout that allows the space for the message to always be there, but empty when there is no message. Not ideal.

You could accomplish the same thing without the empty space in the layout by including an external javascript that inserts the message when the .js on a main site is updated, but that is getting less simple and could be impacted by each site's javascript aggregation and caching issues. Not ideal.

For a solution that is only slightly more complicated, but far more efficient and doesn't require any scripting knowledge, implement https://www.drupal.org/project/sharedblocks. This module allows you to define a View driven block on a the site used to generate the messages as shared and subscribe to that block on every site you'd like to display the messages. This has the added bonus of being able to configure the messages as a content type that are archived so you have a system history as well. Just add either an expiration time or a checkbox to limit the message's active state and filter the View so it returns nothing if there is no active message. The result of an empty block from the parent site on the child sites is the block isn't displayed at all so no need to deal with the space an empty iframe creates. The cache and cron settings for Shared Block are configurable.

UPDATE: Just reviewed the https://www.drupal.org/sandbox/cecrs/2340909 to be promoted to a full project. The module is currently limited to a single alert, but the alert is displayed using a block that can be shared across multiple sites. I've opened a feature request to change that to define an Alert entity, even without that Site Alert + Shared Block is a great solution.

0

Feeds is the way to go, they don't have to be RSS. We have had success with JSON.

On the display side, Views XML backend is a good choice if you don't want to store the notification on the target site. If you do want to store them on the target sites, Features could help bundle up a a common destination content type.

1
  • Feeds is for content - could you explain how to use it for messages instead? – Mołot Oct 29 '14 at 13:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.