定制 avency/neos-cookiebot 二次开发

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

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

avency/neos-cookiebot

最新稳定版本:1.1.0

Composer 安装命令:

composer require avency/neos-cookiebot

包简介

Neos CookieBot package

README 文档

README

A package to integrate Cookiebot into Neos.

Authors & Sponsors

Benjamin Kentsch - benjamin.kentsch@avency.de
Michael Gerdemann - michael.gerdemann@avency.de Enes Erk - enes.erk@avency.de

The development and the public-releases of this package is generously sponsored by our employer https://www.avency.de.

Installation

composer require avency/neos-cookiebot

Configuration

Configure the key in Settings.yaml:

Avency:
  Neos:
    CookieBot:
      key: ''

Or add the mixin to your root page:

  superTypes:
    'Avency.Neos.CookieBot:Mixin.CookieBotKey': true

Block scripts and load on consent

By default, Cookiebot only rewrites the type of <script> tags. With the following helper script, you can also prevent the loading any (external) resources (e.g., scripts and styles) until the appropriate consent is given. After consent, the tags are automatically "unblocked".

Installation / include

Import the script once in your project:

import 'Packages/Plugins/Avency.Neos.CookieBot/Resources/Private/Assets/JavaScript/loadScripts';

Usage

For resources that should be blocked, repklace the attributes with the corresponding data-attributes and set type to text/plain. Set the required consent category via data-cookieconsent (e.g., "marketing").

Example: blocked script

<script
  type="text/plain"
  data-cookieblock-type="text/javascript"
  data-cookieblock-src="https://example.com/script.js"
  data-cookieconsent="marketing"
/>

Result after consent: Once consent for the specified category is granted, the tags are automatically rewritten into loadable resources:

<script
  type="text/javascript"
  src="https://example.com/script.js"
  data-cookieconsent="marketing"
/>

Example: blocked stylesheet

<link
  rel="stylesheet"
  type="text/plain"
  data-cookieblock-type="text/css"
  data-cookieblock-href="https://example.com/styles.css"
  data-cookieconsent="marketing"
/>

Result after consent: Once consent for the specified category is granted, the tags are automatically rewritten into loadable resources:

<link
  rel="stylesheet"
  type="text/css"
  href="https://example.com/styles.css"
  data-cookieconsent="marketing"
/>

Notes

  • data-cookieconsent defines the required consent category (e.g., "marketing"). You can specify multiple categories as a comma-separated list.
  • data-cookieblock-src and data-cookieblock-href hold the blocked URL, which will be applied to src or href after consent.
  • data-cookieblock-type define the target MIME types that will be set after unblocking.
  • The initial type="text/plain" prevents execution or loading before consent.

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

  • Stars: 3
  • Watchers: 2
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-06-22