Code Monkey home page Code Monkey logo

silverstripe-sitebanner's Introduction

Site Wide Banners

Build Status

Allows CMS authors to create site-wide banners, to alert visitors of important information regardless of the page they're viewing.

Features

  • Themeable templates
  • Configure type of alert (defaults to "info", "warning" and "alert")
  • Multiple concurrent alerts
  • Set start/end dates for alert
  • Permission controls
  • Localisation of CMS UI controls and labels
  • Preview and publish through versioning
  • Optional: Rich-text editing (insert links and images)
  • Optional: Sorting through gridfieldextensions
  • Support for subsites

Screenshot

(SilverStripe 3.x)

CMS Preview

CMS editing screen (with versioneddataobjects enabled)

Installation

composer require nzta/silverstripe-sitebanner:

Configuration

Add the following to your YAML config to activate the module:

SilverStripe\SiteConfig\SiteConfig:
  extensions:
    - NZTA\SiteBanner\ExtensionsSiteConfigExtension

The site banner can be configured in admin/settings now.

Templates

In order to show the banners, you need to add them to your template:

<% loop $SiteConfig.SiteBanners %>
    <div class="site-banner site-banner-$Type" role="alert">
        $Content
    </div>
<% end_loop %>

Bootstrap Styles

If you're using Bootstrap, it's easy to get useful default styles for alerts through a combination of contextual backgrounds and icons.

<% loop $SiteConfig.SiteBanners %>
    <% if $Type == 'info' %>
        <p class="bg-info" role="alert">
            <span class="glyphicon glyphicon-info-sign" aria-hidden="true" />
            $Content
        </p>
    <% end_if %>
    <% if $Type == 'warning' %>
        <p class="bg-warning" role="alert">
            <span class="glyphicon glyphicon-warning-sign" aria-hidden="true" />
            $Content
        </p>
    <% end_if %>
    <% if $Type == 'alert' %>
        <p class="bg-danger" role="alert">
            <span class="glyphicon glyphicon-warning-sign" aria-hidden="true" />
            $Content
        </p>
    <% end_if %>
<% end_loop %>

Examples on the SilverStripe default theme:

Info styling

Warning styling

Alert styling

Permissions

By default, every author with access to the "Settings" section (EDIT_SITECONFIG permission code) can set alerts. You can customise this by YAML configuration:

SiteBanner:
  required_permission_codes:
    - ADMIN

Sorting

You can allow authors to sort multiple alerts by installing the gridfieldextensionsn module. It'll get automatically picked up by the code.

Limitations

silverstripe-sitebanner's People

Contributors

chillu avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.