studiomitte/klaro
Composer 安装命令:
composer require studiomitte/klaro
包简介
Cookie consent solution following the GDPR by using the solution Klaro
README 文档
README
This is another cookie consent solution using klaro.
Translations for the following languages are included: de, el, es, fr, hr, hu, it, nl, pl, ro, sk, sl, sr.
Usage
1. Install extension
Use either composer composer require studiomitte/klaro or install the extension via Extension Manager.
2. Setup configuration in sites module
Switch to the sites module and configure the extension. All configurations are described below.
3. Adopt configuration to your needs
Copy one of the JavaScript files in EXT:klaro/Resources/Public/Example/ to your theme extension (or fileadmin), adopt it to your needs and define the path to the file in the site configuration.
Configuration
Site Configuration
The sites module is used for the main configuration.
The following options are available:
Enable: Enable the klaro cookie consent managementPrivacy Page ID: Define the uid of the page with the privacy informationPath to the configuration file: Define the path to the JavaScript file containing the klaro configurationPath to the language file: Use custom xlf files for localization.Show full consent modal: If set, the consent modal is shown when the page is rendered, instead of a small modal in the bottom of the page.Path to the core Klaro JS file: Use alternative version of klaro.Style prefix: Use a custom CSS.
Klaro configuration
Klaro is using a JSON file for its configuration. An example:
var klaroConfig = { cookieExpiresAfterDays: 365, default: true, mustConsent: false, apps: [ { name: 'googleTagManager', title: 'Google Tag Manager', purposes: ['analytics'], required: true }, { name: 'googleAnalytics', title: 'Google Analytics', purposes: ['analytics'], cookies: [/^ga/i], callback: function (consent, app) { if (consent !== false) { window.dataLayer = window.dataLayer || []; window.dataLayer.push({'event': 'loadgtm-analytics'}) } }, } ], }; if (typeof klaroConfigTranslations !== 'undefined') { for (var attr in klaroConfigTranslations) { klaroConfig[attr] = klaroConfigTranslations[attr]; } }
This example will load show 2 apps, Google Tag Manager which is always loaded and Google Analytics. The latter will be loaded by GTM and the callback must be used to actually load it only if the consent is given by the user.
See https://klaro.kiprotect.com/#getting-started for all configuration options
Inline code
To load inline code only after consent, use an example like below:
<script type="opt-in" data-type="application/javascript" data-name="googleAnalytics">(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src= 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); })(window,document,'script','dataLayer','123456');</script>
The src attribute is changed to data-src and the attribute data-name="googleAnalytics" which correlates with the name of the app above.
The JavaScript is then only evaluated if the consent is given.
Privacy Page
It is required that users can change their consent. This is possible by linking to the following pseudo urls.
Use the following pseudo-links
- Open the consent modal:
https://KLARO_CONSENT.com - Reset consent:
https://KLARO_RESET.com
The urls will be replaced dynamically by a JavaScript link which will then trigger the consent modal.
Styling
If the configuration Style prefix is set, it is used as a prefix and you can apply your own CSS rules.
The SCSS files in EXT:klaro/Resources/Private/Scss/ should be copied to your frontend pipeline and modified to your needs.
Credits
This extension was created by Georg Ringer for Studio Mitte, Linz with ♥.
Find more TYPO3 extensions we have developed that provide additional features for TYPO3 sites.
studiomitte/klaro 适用场景与选型建议
studiomitte/klaro 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 26.83k 次下载、GitHub Stars 达 8, 最近一次更新时间为 2019 年 12 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「extension」 「cookies」 「typo3」 「consent」 「gdpr」 「dsgvo」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 studiomitte/klaro 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 studiomitte/klaro 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 studiomitte/klaro 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
Set Links with a specific language parameter
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
UI Kit 3 Extension for Yii2
Adds more BBCode
统计信息
- 总下载量: 26.83k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2019-12-03
