lekoala / silverstripe-cookieconsent
将 cookieconsent.com 集成到 SilverStripe
1.1.0
2021-02-08 11:26 UTC
Requires
- php: >=7.2
- silverstripe/framework: ^4
Requires (Dev)
- sminnee/phpunit: ^5.7
- squizlabs/php_codesniffer: ^3.0
Suggests
- lekoala/silverstripe-defer-backend: use requirements api
This package is auto-updated.
Last update: 2024-09-15 13:04:51 UTC
README
简介
另一个 cookie 允许模块。该模块集成了 https://www.cookieconsent.com/,允许您拥有各种布局(包括阻止布局)并按类型加载/允许 cookie。
注意:即使它与名称(以及版本号)相同,它也不是来自 https://www.osano.com/cookieconsent 的 cookieconsent。
工作原理
当您需要脚本时,您应该添加它们的类型,以便根据用户偏好加载它们
四种类型是
- strictly-necessary
- 功能
- 跟踪
- 定向
并且它们将渲染成这样。请注意 text/plain
类型,它阻止脚本执行。如果您手动包含脚本,这是您应该做的事情。
<script type="text/plain" cookie-consent="strictly-necessary" src="strict.js"> <script type="text/plain" cookie-consent="functionality" src="functional.js"> <script type="text/plain" cookie-consent="tracking" src="tracking-performance.js"> <script type="text/plain" cookie-consent="targeting" src="targeting-advertising.js">
或对于内联脚本
<script type="text/plain" cookie-consent="tracking"> console.log("i'm a tracking script"); </script>
如果您使用 Requirements api,为了指定此额外属性,您需要一个支持它的 Requirements_Backend
。这由我的 defer backend 模块 负责处理。
这是如何使用更新后的 requirements api 添加跟踪脚本的方法
Requirements::javascript('myscript',['cookieconsent' => 'tracking'])
对于 PHP cookie
如果您在服务器端设置 cookie,您可以检查 CookieConsent::isAllowed
方法或使用 CookieConsent::setCookie
助手。
选项
LeKoala\CookieConsent\CookieConsent: # use local js or cdn js use_cdn: false # class name of your privacy page. leave blank for default privacy_notice_class: 'PrivacyNoticePage' opts: # simple, headline, interstitial, standalone notice_banner_type: "interstitial" # implied, express => should really by express for GDPR consent_type: "express" # light, dark palette: "dark" change_preferences_selector: "#cookieconsent-preferences"
检查合规性
您可以使用 cookiebot 检查合规性 https://www.cookiebot.com/en/gdpr-cookies/
这也可以帮助客户认识到此模块的必要性
兼容性
在 4.6 上测试过,但应在任何 ^4 项目上工作
维护者
LeKoala - thomas@lekoala.be