nzta/silverstripe-sitebanner 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nzta/silverstripe-sitebanner

Composer 安装命令:

composer require nzta/silverstripe-sitebanner

包简介

Site-wide banners activated through the CMS

README 文档

README

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
  • CMS users can make banners "dismissible", allowing users to hide banners after reading.
  • Rich-text editing (insert links and images)
  • Optional: Sorting through gridfieldextensions
  • Support for subsites

Screenshot

CMS Preview

Requirements

  • php >= 8.0
  • SilverStripe ^5

For a Silverstripe CMS ^4 compatible version of this module, please see the releases <=3.0.1.

Installation

composer require nzta/silverstripe-sitebanner

Configuration

Site settings

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

SilverStripe\SiteConfig\SiteConfig:
  extensions:
    - NZTA\SiteBanner\Extensions\SiteConfigExtension

Add the following environment variable to you .env file to activate the module in site settings:

SITEBANNER_SITECONFIG=1

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

Note: The site settings interface is a legacy feature that exists to keep background compatibility for anyone who still want to use this interface. This feature won't receive future updates, and we recommend using the default implementation with model admin. With admin model we are not forced to expose site settings to CMS users who must only be allowed to managed site banners.

Model admin

By default, the site banners are managed from the model admin interface.

Templates

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

<% loop $SiteBanners %>
    <div id="site-banner-$ID" class="site-banner site-banner-$Type site-banner--hidden" role="alert" data-id="$ID" aria-hidden="true" data-nosnippet>
        $Content
        <% if $Dismiss %>
            <button class="site-banner-close" aria-label="Close" data-id="$ID">×</button>
        <% end_if %>
    </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 $SiteBanners %>
    <% if $Type == 'info' %>
        <p class="bg-info site-banner site-banner-$Type site-banner--hidden" role="alert" data-id="$ID" aria-hidden="true" data-nosnippet>
            <span class="glyphicon glyphicon-info-sign" aria-hidden="true" />
            $Content
        </p>
    <% end_if %>
    <% if $Type == 'warning' %>
        <p class="bg-warning site-banner site-banner-$Type site-banner--hidden" role="alert" data-id="$ID" aria-hidden="true" data-nosnippet>
            <span class="glyphicon glyphicon-warning-sign" aria-hidden="true" />
            $Content
        </p>
    <% end_if %>
    <% if $Type == 'alert' %>
        <p class="bg-danger site-banner site-banner-$Type site-banner--hidden" role="alert" data-id="$ID" aria-hidden="true" data-nosnippet>
            <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

Features

Display banners only on the selected pages

NZTA\SiteBanner\Extensions\PageSelectionExtension

Add the followig to your YML file to enable the fature

---
Name: app-sitebanenr
After: sitebanner
---

NZTA\SiteBanner\Extensions\PageSelectionExtension:
  enabled: true

Then you are going to have a tab with gridfield to select the pages a banner must be visible on that page only.

In template, you will need to pass the page ID to <% loop $SiteBanners($PageID) %>

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:

NZTA\SiteBanner\Models\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

nzta/silverstripe-sitebanner 适用场景与选型建议

nzta/silverstripe-sitebanner 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 38.96k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2017 年 05 月 16 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「cms」 「banner」 「silverstripe」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 nzta/silverstripe-sitebanner 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 nzta/silverstripe-sitebanner 我们能提供哪些服务?
定制开发 / 二次开发

基于 nzta/silverstripe-sitebanner 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 38.96k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 10
  • Watchers: 7
  • Forks: 12
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2017-05-16