A Drupal 10 module that integrates Revive Adserver into Drupal's block layout system. Each configured ad zone becomes an independently placeable block, with server-side campaign detection and a developer mode for local layout work.
- Drupal 10
- Drupal core
blockmodule - A running Revive Adserver instance (only required in production mode)
- Place this module in
web/modules/custom/revive_ads/. - Enable it:
drush en revive_ads(or via Extend). - Visit Admin > Configuration > Web services > Revive Ads (
/admin/config/services/revive-ads) to configure.
| Setting | Description |
|---|---|
| Revive server URL | Base URL of your Revive instance, e.g. https://ads.example.com. No trailing slash. |
| Zone status cache lifetime | How long (5 min – 4 hours) each zone's active/empty result is cached before re-checking Revive. |
Enable Developer mode to bypass all Revive requests. Each ad block renders a local SVG placeholder instead of making HTTP calls. Use this on local and staging environments.
When developer mode is on, blocks always render regardless of whether a campaign is active — so skyscraper detection and layout work correctly without a live ad server.
Each zone row creates one placeable block in Drupal's block layout UI (Admin > Structure > Block layout).
| Column | Description |
|---|---|
| Block title | Display name shown in the block layout UI. |
| Zone ID | Numeric zone ID from your Revive Adserver. |
| Dev placeholder | SVG image shown when developer mode is active. |
Drag rows by their handle to reorder zones. The order is cosmetic only (for the admin form) — it does not affect front-end rendering.
Adding a custom placeholder: Drop any .svg file into images/placeholders/ and clear caches. It will appear automatically in the dev placeholder select.
The module ships with nine default zones that match a standard news site layout:
| Block title | Zone ID | Placeholder |
|---|---|---|
| Left Skyscraper | 19 | Skyscraper |
| Right Skyscraper | 20 | Skyscraper |
| MPU One | 2 | MPU |
| MPU Two | 4 | MPU |
| MPU Three | 6 | MPU |
| Leaderboard One | 22 | Leaderboard |
| Leaderboard Two | 29 | Leaderboard |
| Large Banner | (set your zone ID) | Large Banner |
| Standard Banner | (set your zone ID) | Standard Banner |
- Block derivation — The deriver (
ReviveAdBlockDeriver) readsrevive_ads.settingsand creates one block plugin derivative per zone. Derivatives are rebuilt on cache clear. - Zone checking —
ReviveZoneCheckermakes a server-side GET request to Revive'sasyncspc.phpendpoint and checks whether the response contains any ad HTML. Results are cached per zone for the configured TTL. On any HTTP error the service fails open (returnstrue) so a Revive outage never collapses the layout. - Rendering — In production, blocks output an
<ins>tag and the Revive async JS. In developer mode, blocks render a local SVG placeholder.
# Kernel tests (fast, no browser)
ddev drush php:script --script-path=. -- phpunit web/modules/custom/revive_ads/tests/src/Kernel
# Functional tests (requires a site install)
ddev exec ./vendor/bin/phpunit web/modules/custom/revive_ads/tests/src/FunctionalOr from the project root via PHPUnit directly:
ddev exec ./vendor/bin/phpunit --group revive_adsrevive_ads/
├── config/
│ ├── install/revive_ads.settings.yml # Default config (zones, server URL, etc.)
│ └── schema/revive_ads.schema.yml # Config schema
├── images/placeholders/ # SVG placeholder images for developer mode
├── js/revive-callback.js # Handles the Revive ad-empty callback
├── src/
│ ├── Form/ReviveAdsSettingsForm.php # Admin settings form
│ ├── Plugin/Block/ReviveAdBlock.php # Block plugin
│ ├── Plugin/Deriver/ReviveAdBlockDeriver.php
│ └── Service/ReviveZoneChecker.php # Zone active-campaign checker
├── templates/revive-ad-block.html.twig
└── tests/
├── src/Functional/ReviveAdsSettingsFormTest.php
└── src/Kernel/
├── ReviveAdBlockDeriverTest.php
└── ReviveZoneCheckerTest.php