balazscsaba2006/cookiebot

CookieBot集成到Craft CMS 3。

2.1.2 2022-10-05 12:51 UTC

This package is auto-updated.

Last update: 2024-09-05 17:04:28 UTC


README

CookieBot集成到Craft CMS 3或4。

要求

此插件需要Craft CMS 3.0.0或更高版本。

安装

  • 使用Composer进行安装: composer require balazscsaba2006/cookiebot
  • 导航到 设置 -> 插件 并点击“安装”按钮

配置

  • 导航到 设置 -> 插件 并配置Cookiebot的设置

覆盖插件设置

如果您在 config/ 文件夹中创建了一个名为 cookiebot.php配置文件,则可以在控制面板中覆盖插件的设置。由于该配置文件完全 支持多环境,这是一种在不同环境中使用不同设置的便捷方法。

以下是该配置文件可能的样子以及您可以覆盖的所有可能值的列表。

    <?php

    return [
        'domainGroupID' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
        'defaultPreferences' => true,
        'defaultStatistics' => true,
        'defaultMarketing' => false
    ];

用法

可用于在Twig模板上渲染对话框和声明脚本

渲染对话框脚本

{{ craft.cookiebot.dialogScript()|raw }}

渲染声明脚本

{{ craft.cookiebot.declarationScript()|raw }}

以特定语言渲染对话框/声明脚本

{# dialog script #}
{{ craft.cookiebot.dialogScript(craft.app.locale.id)|raw }}

{# declaration script #}
{{ craft.cookiebot.declarationScript(craft.app.locale.id)|raw }}

可用于检查特定cookie类别(如:偏好、统计和营销)的同意。

检查任何同意

{% if craft.cookiebot.hasConsent %}
    {# ... #}
{% endif %}

检查特定类别的同意

偏好

{% if craft.cookiebot.hasPreferencesConsent %}
    {# ... #}
{% endif %}

统计

{% if craft.cookiebot.hasStatisticsConsent %}
    {# ... #}
{% endif %}

营销

{% if craft.cookiebot.hasMarketingConsent %}
    {# ... #}
{% endif %}