Contensio logo

Announcement Bar

Dismissible announcement bar for Contensio — text, link, color, and schedule.

About this plugin

Announcement Bar - Contensio plugin

<p> <a href="https://packagist.org/packages/contensio/plugin-announcement-bar"><img src="https://img.shields.io/packagist/v/contensio/plugin-announcement-bar?label=packagist" alt="Latest Version"></a> <a href="LICENSE"><img src="https://img.shields.io/badge/license-AGPL--3.0--or--later-blue" alt="License"></a> </p>

Display a dismissible announcement strip at the very top of every page on your site - above the header. Set the message text, an optional call-to-action link, background and text colors, and an optional schedule (show from / hide after).

Typical uses: sale announcements, shipping notices, event countdowns, maintenance warnings, new feature launches.

Install

Option A - Composer (developers)

composer require contensio/plugin-announcement-bar

Then in the Contensio admin: Plugins → Enable next to "Announcement Bar".

Option B - ZIP upload

  1. Download the latest release ZIP from the releases page
  2. In Contensio admin: Plugins → Install Plugin → upload the ZIP
  3. Click Enable

Configure

After enabling:

  1. Go to Tools → Announcement Bar (or Configuration → Announcement Bar)
  2. Check Enable announcement bar
  3. Enter your announcement text (max 300 characters)
  4. Optionally add a link URL and link label (e.g. "Shop now → /sale")
  5. Pick background color and text color using the color pickers - the live preview updates instantly
  6. Choose whether visitors can dismiss the bar
  7. Optionally set a schedule: the bar auto-shows and auto-hides at the specified date/times
  8. Save - the bar appears immediately at the top of every page

How it works

  • The bar is injected as the first element inside <body>, before the site header, via the contensio/frontend/body-start render hook. No theme files are modified.
  • The server checks the schedule (starts_at / ends_at) and only renders the bar HTML if the current time is within the window. Visitors outside the window never receive the HTML.
  • If dismissible is on, a close button appears. When clicked, the bar's state is stored in sessionStorage under the key ab_dismissed_{hash}. This means:
    • The bar stays hidden for the rest of the browser session
    • It reappears when the visitor opens a new session (new tab, new browser window, next day)
    • If you change the announcement text or link, the hash changes automatically, so all visitors see the new bar regardless of previous dismissals

Scheduling

The schedule fields are optional. Behavior:

starts_at ends_at Result
not set not set Bar shows whenever enabled is checked
set not set Bar shows from that date/time onwards
not set set Bar shows until that date/time, then disappears
both set both set Bar shows only within that window

The schedule is evaluated server-side on every request - no cron job needed.

Architecture notes

  • Settings stored as a single JSON blob in the core settings table (module = announcement_bar, setting_key = config). No migrations needed.
  • Frontend bar is pure HTML + inline CSS + a small inline <script> block. No JavaScript framework, no external requests.
  • Admin settings page includes a live preview with synchronized color pickers (native <input type="color"> + hex text input).
  • A settings hub card is injected into the admin Configuration page via the contensio/admin/settings-cards hook.
  • Injected via contensio/frontend/body-start - a hook point added in Contensio core v2.0.0.

License

AGPL-3.0-or-later. Copyright © 2026 Iosif Gabriel Chimilevschi. Operated by Host Server SRL.