定制 gridonic/statamic-consent-manager 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

gridonic/statamic-consent-manager

Composer 安装命令:

composer require gridonic/statamic-consent-manager

包简介

A Statamic 3 addon to manage consent for cookies.

README 文档

README

A Statamic 3 addon to manage consent for cookies 🍪.

Features

  • Define consent groups and scripts loaded dynamically only when consent for a group is given.
  • Provides a simple javascript API to read and change consent for users.
  • Consent is stored client-side only, making it possible to use the static cache.

Installation

Run the following commands:

composer require gridonic/statamic-consent-manager
php artisan vendor:publish --tag=statamic-consent-manager-config

Configuration

Edit the configuration file located in config/statamic/consent_manager.php:

<?php

return [
    // Where to store the consent settings of any user (javascript).
    // Choose "local" for local storage or "session" for session storage.
    'storage' => 'local',

    // Consent groups managed by the addon. Feel free to change, remove or add your own groups.
    // Scripts are dynamically added to the DOM only if consent for their group is given.
    'groups' => [
        'necessary' => [
            'required' => true,
            'consented' => true,
            'scripts' => [
                [
                    // The full script tag to include in the page if consent is given.
                    'tag' => '<script>console.log(\'script dynamically loaded with consent manager\');</script>',
                    // Choose "head" or "body" to append the script to the page.
                    'appendTo' => 'head',
                ],
            ],
        ],
        'marketing' => [
            'required' => false,
            'consented' => false,
            'scripts' => [],
        ],
        'statistics' => [
            'required' => false,
            'consented' => false,
            'scripts' => [],
        ]
    ],
];

Usage

  1. Define your consent groups and their scripts in the configuration.
  2. Add the {{ consent_manager }} tag in the head of your layout.

That's it! 🥳 What's left up to you is to design a nice cookie banner and modify consent data by using the javascript API.

Rendering a cookie banner

The addon provides the tag {{ consent_manager:groups }} which can be used to loop over consent groups in Antlers.

{{ consent_manager:groups }}
    Group ID: {{ id }}
    Consented by default: {{ consented }}
    Required: {{ required }}  
{{ /consent_manager:groups }}

ℹ️ To read of modify consent, you need to use the javascript API, because the data is stored client-side only.

Javascript API

The addon exposes a window.consentManager object to read and write consent data.

Method Description
getConsent(group: string): boolean Check if the user has consented to a group.
setConsent(group: string, consent: boolean) Set or remove consent to a group. If consent is given, all scripts of the group are appended to the DOM.
isRequired(group: string): boolean Check if a group is required.
getGroups(): Array Get all consent groups.
getGroup(group: string): Object Get information about a single group.

gridonic/statamic-consent-manager 适用场景与选型建议

gridonic/statamic-consent-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 272 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 08 月 26 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 gridonic/statamic-consent-manager 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 272
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 14
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2021-08-26