PHPackages                             jakxnz/silverstripe-announce - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jakxnz/silverstripe-announce

ActiveSilverstripe-vendormodule[Utility &amp; Helpers](/categories/utility)

jakxnz/silverstripe-announce
============================

Display announcement messages for SilverStripe

14771PHP

Since Jul 30Pushed 7y ago1 watchersCompare

[ Source](https://github.com/codecraft/silverstripe-announce)[ Packagist](https://packagist.org/packages/jakxnz/silverstripe-announce)[ RSS](/packages/jakxnz-silverstripe-announce/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

silverstripe-announce
=====================

[](#silverstripe-announce)

Announce things to the page controller &amp; view in SilverStripe. Can be used to power plain messages, modals, alerts, and callouts.

Multiple announcements can be stacked.

Announcements can be templated to match component libraries such as Bootstrap.

Installation
------------

[](#installation)

**Note:** For a similar module in SilverStripe 3, consider using [axyr/silverstripe-flashmessage](https://github.com/axyr/silverstripe-flashmessage)

### Requirements

[](#requirements)

- SilverStripe &gt;= 4.0
- PHP &gt;= 5.6

**Composer**

`composer require jakxnz/silverstripe-announce`

**SilverStripe**

`dev/build?flush=all` your SilverStripe project.

Introduction
------------

[](#introduction)

Create announcements with Titles, Headings, Contents, Footers and Actions. Control whether they should be stored for later responses. Control whether they should be dismissable.

Announcements are retained at StilverStripe's `Controller`, and stored in the Announcement store (default is `$_SESSION`).

Each announcement is made available to the view via a SilverStripe `Controller` extension.

Only one set of announcements can be stacked at a time.

The announcement store can be replaced with a custom class that implements `AnnouncementStoreInterface`;

Usage
-----

[](#usage)

Queue a new announcement

```
Announcements::queue('AnnouncementName', 'Announcement Title', 'This is an announcement message');

```

`Accounments::queue()` will accept all arguements for an `Announcement`

Queue an existing announcement

```
$msg = Announcement::create('AnnouncementName', 'Announcement Title', 'This is an announcement message');

Announcements::queue($msg);

```

Get all current announcements

```
$announcements = Announcements::get();

```

Get an announcement by name

```
Announcements::get()->getByName('AnnouncementName');

```

Get an announcement by type

```
Announcements::get()->getByType(Announcement::DEFAULT);

```

Clear the announcements queue

```
Announcements::clear();

```

Display announcements in the top scope of a template

```

    $Announcements

```

### Customise an announcement

[](#customise-an-announcement)

Example of all options

```
use CodeCraft\Announce\Model\Announcement;
use CodeCraft\Announce\Model\Action;

...

$announcement = Announcement::create(
    $name = 'AnnouncementName',
    $title = 'Announcement Title',
    $content = 'A plain or html string',
    $heading = 'A plain or html string',
    $footer = 'A plain or html string',
    $actions = [
        Action::create(
            $name = 'ActionName',
            $content = 'A plain or html string',
            $type = Action::BUTTON,
            $link = 'https://www.google.com/',
            $extraClass = 'btn btn-primary'
        )
    ],
    $type = Announcement::DEFAULT
)
    // Store announcement
    ->setStoreable(true)

    // Dismissable
    ->setDismissable(true)

    // Name
    ->setName('AnnouncementName')

    // Title
    ->setTitle('Announcement Title')
    ->setTitle('Announcement Title')

    // Content
    ->setContent('Announcement body')
    ->setContent('Announcement body')

    // Heading
    ->setHeading('Announcement heading')
    ->setHeading('Announcement heading')

    // Footer
    ->setFooter('Announcement footer')
    ->setFooter('Announcement footer')

    // Action
    ->addAction(
        Action::create()
            ->setName('ActionName')
            ->setContent('OK')
            ->setContent('OK')
            ->setType(Action::BUTTON)
            ->setLink('http://www.google.com/')
            ->addExtraClass('btn btn-primary')
            ->setAttribute('title', 'A helpful title')
    )

    // Type
    ->setType(Announcement::DEFAULT)

    // Template
    ->setTemplate('templates\CodeCraft\Announce\Announcement');

```

### Announcement store

[](#announcement-store)

Access the announcement store

```
Announcements::get()->getStore();

```

Expect announcements to be stored as an `array`

#### Set storable

[](#set-storable)

Announcements are stored by default, so that they can be included in the next relevant response.

Define if the announcement should be stored

```
$msg = Announcement::create('AnnouncementName', 'Un-stored Announcement', 'This announcement is not stored')
    ->setStoreable(false);

```

### Custom announcement template

[](#custom-announcement-template)

Set a custom template for all announcements by [overloading templates](#overloading-templates)

Set a custom template for any announcement

```
$msg = Announcement::create('AnnouncementName', 'Announcement Title', 'This is an announcement message')
    ->setTemplate('MyTemplate');

```

### Overloading templates

[](#overloading-templates)

**Announcement template**

Overload the default template for all announcement actions by overloading `templates/CodeCraft/Announce/Model/Announcement`

**Announcement Action template**

Overload the default template for all announcement actions by overloading `templates/CodeCraft/Announce/Model/Action`

Read more about SilverStripe [Template Inheritance](https://docs.silverstripe.org/en/4/developer_guides/templates/template_inheritance/)

### Announcements by name

[](#announcements-by-name)

Each announcement name is distinct. Call announcements by name

**Back-end**

```
Announcements::get()->getByName('AnnouncementName');

```

**Template**

```
$Announcements.ByName('AnnouncementName');

```

### Announcements by type

[](#announcements-by-type)

Set any announcement's type with one of the available types; `Announcement::DEFAULT`, `Announcement::MODAL`, `Announcement::TRAY`, `Announcement::MESSAGE`, or `Announcement::CALLOUT`.

```
$msg = Announcement::create('Name')->setType(Announcement::MODAL);

```

Call announcements by type

**Back-end**

```
Announcements::get()->getByType(Announcement::MODAL);

```

**Template**

```
$Announcements.ByType('modal');

```

*Can be 'default', 'modal', 'tray', 'message', 'callout'*

Limitations
-----------

[](#limitations)

- Does not have any CMS editable functionality

License
-------

[](#license)

Modified BSD License

Copyright (c) 2018, Jackson Darlow

Read the [license](https://github.com/codecraft/silverstripe-announce/blob/master/LICENSE)

To do
-----

[](#to-do)

- Tests
- Add redundancies for cases where announcement store is ahead of announcement stack
- Add a way to disable the store
- Create a database announcement store
- Create a redis announcement store
- Replace Announcement type constants with an object-oriented model
    - Create an email Announcement type
- An announcement history for user-focused announcements
    - Flag announcement when viewed by user
- Add CMS editable announcements, similiar to [nzta/silverstripe-sitebanner](https://github.com/NZTA/silverstripe-sitebanner)
- Version CMS editable announcements

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity40

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1634995?v=4)[Jackson Darlow](/maintainers/jakxnz)[@jakxnz](https://github.com/jakxnz)

---

Top Contributors

[![jakxnz](https://avatars.githubusercontent.com/u/1634995?v=4)](https://github.com/jakxnz "jakxnz (1 commits)")

### Embed Badge

![Health badge](/badges/jakxnz-silverstripe-announce/health.svg)

```
[![Health](https://phpackages.com/badges/jakxnz-silverstripe-announce/health.svg)](https://phpackages.com/packages/jakxnz-silverstripe-announce)
```

###  Alternatives

[nabilhassen/laravel-usage-limiter

A laravel package to manage and limit usages/seats by plan, users, or other models

1853.8k](/packages/nabilhassen-laravel-usage-limiter)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
