pringuin/dataprivacybundle

Pimcore的Dataprivacy Bundle

安装量: 2,889

依赖者: 0

建议者: 0

安全: 0

星标: 11

关注者: 5

分支: 4

开放问题: 1

语言:JavaScript

类型:pimcore-bundle

v2.2 2024-05-13 12:28 UTC

This package is auto-updated.

Last update: 2024-09-13 13:08:02 UTC


README

将dataprivacy功能(GDPR / DSGVO)添加到Pimcore

2.x版本可用于Pimcore 11。使用1.x版本(分支pimcore-x)用于Pimcore X。使用0.x版本(分支pimcore-6)用于Pimcore 5/6

功能

  • 支持多个域名(使用Pimcore站点)
  • 在pimcore项目中轻松安装(即插即用解决方案)
  • 管理员界面配置跟踪器和工具
  • 前端具有cookie和跟踪同意功能

Backend Interface

依赖项

此包包含tarteaucitron.js脚本,位于pringuin/DataprivacyBundle/Resources/public/js/tarteaucitron文件夹中。

安装

Composer安装

  1. 将以下代码添加到您的composer.json文件中或通过命令行安装
"require": {
"pringuin/dataprivacybundle" : "^2.0"
}

添加包

将包添加到您的Kernel中的src/Kernel.php,如下所示

public function registerBundlesToCollection(BundleCollection $collection): void
{
$collection->addBundle(new pringuinDataprivacyBundle(), 70);
}

您可能还需要将其添加到pimcores的config/bundles.php

    \pringuin\DataprivacyBundle\pringuinDataprivacyBundle::class => ['all' => true],

安装资源

在通过composer安装Dataprivacy Bundle后

  • 执行:$ bin/console assets:install

配置跟踪器、工具和服务

现在后端配置应在您的pimcore管理后台的搜索下方可用。您可以在那里设置您的跟踪ID(例如,您的UA-XXXXXXXX-X)。这将在文件夹PIMCOREINSTALLATION/config/pringuin_dataprivacy中生成文件。默认站点的文件将是siteconfig_default.yml。下一个站点将遵循pimcore ID,看起来像siteconfig_1.ymlsiteconfig_2.yml。您也可以直接使用您喜欢的IDE修改这些文件。它们可以使用git存档。

将安装集成到模板中

要将cookie同意集成到您的前端布局中,您可以使用以下twig代码。只需将其插入到您的模板(例如layout.html.twig)中,在关闭body标签之前即可

{{ render(controller('pringuin\\DataprivacyBundle\\Controller\\DefaultController::defaultAction', [])) }}

提示:您始终可以通过在文件夹PIMCOREINSTALLATION/app/Resources/pringuinDataprivacyBundle/views/default/default.html.twig中实现自己的模板来覆盖此模板

Default Frontend Interface

按钮颜色调整

您始终可以使用自己的CSS覆盖tarteaucitron的默认CSS。如果您想保留默认CSS,但所有按钮都使用相同的颜色(例如,根据TTDSG的要求),则可以使用以下CSS

html body #tarteaucitronRoot #tarteaucitron .tarteaucitronAllow, html body #tarteaucitronRoot #tarteaucitron .tarteaucitronDeny,
html body #tarteaucitronRoot #tarteaucitronAlertBig .tarteaucitronAllow, html body #tarteaucitronRoot #tarteaucitronAlertBig .tarteaucitronDeny, html body #tarteaucitronRoot #tarteaucitronAlertBig #tarteaucitronCloseAlert,
#tarteaucitronAlertBig #tarteaucitronCloseAlert, #tarteaucitronAlertBig #tarteaucitronPersonalize, .tarteaucitronCTAButton, #tarteaucitron #tarteaucitronPrivacyUrl, #tarteaucitron #tarteaucitronPrivacyUrlDialog, #tarteaucitronRoot .tarteaucitronDeny {
    background: black !important;
    color: white !important;
}

支持的跟踪器和工具

此软件包目前包含以下跟踪器和/或工具集成

  • Crazy Egg
  • eKomi
  • eTracker
  • Facebook Pixel
  • Google Analytics(支持不同的实现)
  • Google Adwords Remarketing
  • Google Fonts
  • Google Tag Manager
  • Hubspot
  • Matomo(以前称为Piwik)
  • Mautic
  • Zopim
  • YouTube
  • Vimeo
  • Dailymotion

请注意,您需要负责实现视频模块以使YouTube、Vimeo和Dailymotion工作。

示例代码来自 breakone

{% set autoplay = autoplay.isChecked() ? true : false %}
{% set loop = loop.isChecked() ? true : false %}
{% set mute = muted.isChecked ? true: false %}

{% set video = pimcore_video('video') %}

{% if video.getVideoType == 'youtube' %}
  <div class="pimcore_tag_video pimcore_editable_video ">
    <div class="youtube_player" videoID="{{ video.id }}" width="{{ width }}" height="auto" theme="dark" rel="0" controls="1" showinfo="0" autoplay="{{ autoplay }}" mute="{{ mute }}" srcdoc="srcdoc" loop="{{ loop }}" loading="0"></div>
  </div>
{% elseif video.getVideoType == 'vimeo' %}
  <div class="pimcore_tag_video pimcore_editable_video ">
    <div class="vimeo_player" videoID="{{ video.id }}" width="{{ width }}" height="auto" autoplay="{{ autoplay }}" mute="{{ mute }}" loop="{{ loop }}"></div>
  </div>
{% elseif video.getVideoType == 'dailymotion' %}
  <div class="pimcore_tag_video pimcore_editable_video ">
    <div class="dailymotion_player" videoID="{{ video.id }}" width="{{ width }}" height="auto" showinfo="0" autoplay="{{ autoplay }}" embedType="video"></div>
  </div>
{% else %}
  {{ video|raw }}
{% endif %}

添加您自己的跟踪器或工具同意

如果缺少追踪器或工具,请首先检查该工具是否集成到 tarteaucitron.js 中。您可以通过源代码或官方 tarteaucitron.js 网站 使用安装指南来完成此操作。

如果追踪器或工具没有被包含在 tarteaucitron.js 包中,请首先将其集成到其中(他们接受拉取请求)。或者,您可以直接使用 tarteaucitron.js 中的此示例代码直接包含您自定义的服务

tarteaucitron.services.mycustomservice = {
    "key": "mycustomservice",
    "type": "social|analytic|ads|video|support",
    "name": "MyCustomService",
    "needConsent": true,
    "cookies": ['cookie', 'cookie2'],
    "readmoreLink": "/custom_read_more", // If you want to change readmore link
    "js": function () {
        "use strict";
        // When user allow cookie
    },
    "fallback": function () {
        "use strict";
        // when use deny cookie
    }
};
(tarteaucitron.job = tarteaucitron.job || []).push('mycustomservice');

要将 tarteaucitron.js 包中包含的追踪器或工具添加到此包,您必须执行以下步骤

添加到默认配置

默认配置是所有网站特定配置的基础。对默认配置的更改也将更改您的网站配置文件。默认配置位于 Resources/var/defaultconfiguration.yml

添加视图输出

模板所需的代码可以在 tarteaucitron.js 安装说明 中轻松找到。只需选择免费手动安装并滚动到下一步。搜索您的服务以获取安装代码,通常如下所示

<script type="text/javascript">
    tarteaucitron.user.etracker = 'data-secure-code';
    (tarteaucitron.job = tarteaucitron.job || []).push('etracker');
</script>

将其添加到 Resources/views/default/default.html.twig 文件中的其他代码中,并用当前实现追踪器和工具中所示的方式将动态参数(如上面的 data-secude-code)替换为 twig 值。

添加翻译

最后,在文件 Resources/translations/admin.en.yml 和/或 admin.de.yml 中添加后端翻译条目。键将与您在 defaultconfiguration.yml 中使用的键相同。您也可以将 _helptext 追加到键中,为编辑器插入自定义的 helptext。

最后一步

测试您的实现,并在本存储库中创建一个拉取请求,以便现在每个人都可以使用您新实现的服务、追踪器或工具。谢谢!

更新

从 1.0 更新到 2.0

2.0 是 Pimcore 11 的第一个版本。只需调整您的 composer.json 并像往常一样运行 composer update。

如果 composer 没有运行,请执行: $ bin/console assets:install

您可能还需要再次保存您的配置。

从 0.5 更新到 1.0

1.0 是 Pimcore X 的第一个版本。只需调整您的 composer.json 并像往常一样运行 composer update。

由于 pimcore 从 twig 模板中删除了 pimcore_action,您必须调整您的模板安装。

之前

{{ pimcore_action('default', 'default', 'pringuinDataprivacyBundle', {}) }}

现在

{{ render(controller('pringuin\\DataprivacyBundle\\Controller\\DefaultController::defaultAction', [])) }}

您可能还需要再次保存您的配置。

从 0.4 更新到 0.5

要更新到 0.5,只需调整您的 composer.json 并像往常一样运行 composer update。根据您的安装情况,您可能需要运行命令 php bin/console assets:install web 来安装新的 tarteaucitron.js 版本(1.9.5 现已包含),如果您作为硬盘安装。此版本还添加了新的默认配置设置。您可能需要再次保存您的配置。

从初始版本、0.1、0.2 或 0.3 更新到 0.4

要从第一版或 0.1/0.2 版本更新到 0.3,只需调整您的 composer.json 并像往常一样运行 composer update。根据您的安装情况,您可能需要运行命令 php bin/console assets:install web 来安装新的 tarteaucitron.js 版本(1.8.4 现已包含),如果您作为硬盘安装。

贡献

虽然我们认为这个捆绑包稳定且已准备好投入生产使用,但我们非常愿意如果通过拉取请求改进此捆绑包,以支持我们和整个 pimcore 社区。这是我们第一个公开的 pimcore 捆绑包,所以建设性的反馈也非常受欢迎!

版权和许可证

版权:PRinguin GbR
有关许可证详细信息,请访问 LICENSE.md