Skip to content

Configuration

A platform has two kinds of sites:

  • Sites that show announcements install Platform Announcements and read a feed.
  • The site that publishes them, usually the platform's own site, also installs the Platform Announcements Source submodule, which serves the feed.

Platforms where every site imports the same configuration set up both through that configuration, and keep the differences in settings.php: see Platforms with shared configuration.

Sites that show announcements

Uninstall core's Announcements module first: both modules add an Announcements page and toolbar tab, and the status report shows an error while both are installed. Then install Platform Announcements as you would normally install a contributed Drupal module (see Installing Drupal Modules).

  1. Go to Administration » Configuration » Web services » Platform announcements (/admin/config/services/platform-announcements).
  2. Enter the Feed URL, such as https://www.example.com/announcements.json, and optionally the Announcements page URL for the "View all announcements" link.
  3. Grant the "Access platform announcements" permission to the roles that should see announcements.
  4. Optionally, place the Platform announcements block.

The feed is a JSON Feed with the same keys as Drupal.org's announcements feed. Only announcements that link to the feed's own site are shown. The feed is fetched again on cron once the cached copy expires (after a day), and as soon as the feed URL changes. See Feed format for the details.

Dismissals are kept in the browser's localStorage, so they don't follow people to another browser or device. Storing them per user on the server may be added later.

The site that publishes them

On the platform's own site, install the Platform Announcements Source submodule. It requires core's Node, RESTful Web Services, Serialization, Text and Views modules, and adds:

  • a Platform announcement content type, with Content and Featured fields;
  • a Platform announcements view, which serves the feed at /announcements.json.

Then mark the site as the source of announcements in its settings.php:

$settings['platform_announcements_source'] = TRUE;

and rebuild caches. Without this setting, the feed is denied and nobody can create announcements, apart from people with the "Bypass content access control" permission.

Publish Platform announcement content, then point each site's Feed URL at https://<platform site>/announcements.json.

To change what the feed contains, edit the view: the Announcements JSON Feed style maps the view's fields to the feed's title, content, link, dates and featured flag. See Feed format for the keys sites read.

Platforms with shared configuration

On platforms where every site imports the same configuration, install both modules on every site through that configuration, and let each site's settings.php decide what it does:

  • On the site that publishes announcements, set $settings['platform_announcements_source'] = TRUE;. On every other site, the content type and feed are there but can't be used.
  • Set the feed URL for each environment, since the shared configuration can't hold a different host per environment:

    $config['platform_announcements.settings']['feed_url'] = 'https://announcements.example.com/announcements.json';
    
  • Export the placed Platform announcements block with the rest of the configuration, so every site shows it in the same place.

This follows the usual approach of keeping per-site and per-environment differences in settings.php, rather than in separate copies of the configuration.