taitava / silverstripe-eucookielawpopup
用于在 SilverStripe CMS 中方便使用 wimagguc/jquery-eu-cookie-law-popup 的包装器。
1.2.0
2018-11-12 14:19 UTC
Requires
- silverstripe/cms: ^4.0
- silverstripe/framework: ^4.0
This package is auto-updated.
Last update: 2024-09-06 19:43:53 UTC
README
使用 jQuery 和 wimagguc/jquery-eu-cookie-law-popup 创建一个弹出元素,通知访客该网站使用Cookies。请注意,此模块基本上只是后者提到的库的包装器,以便在 SilverStripe 项目中轻松实现。
要求
此模块需要 SilverStripe 4.x 框架。还需要 CMS 模块。
安装
1. 使用 composer 安装模块
composer require "taitava/silverstripe-eucookielawpopup:*"
2. 在您的主题的 ***templates/Page.ss 模板中添加此 HTML 片段
<div class="eupopup"></div>
弹出消息将被渲染到该元素中。如果您想更改 class
属性或使用 ID
属性而不是 class
,您可以在应用程序的 YAML 配置中配置自定义 jQuery 选择器
创建一个文件 app/_config/eucookielawpopup.yml
--- Name: customeucookielawpopup After: - '#eucookielawpopup' --- Taitava\EUCookieLawPopup\EUCookieLawPopup: popup_element_jquery_selector: '.eupopup'
请记住,在更改选择器后,在浏览器中运行 /dev/build?flush=all
3. 所有配置选项
这些是默认值
--- Name: customeucookielawpopup After: - '#eucookielawpopup' --- Taitava\EUCookieLawPopup\EUCookieLawPopup: enabled: true #If true, 'EU cookie law popup' related CSS and JavaScript files are automatically defined as requirements during each page request. use_jquery_from_framework: true #If true, adds jquery from SS framework as a requirement automatically. Requires $enabled config value to be true too, otherwise does nothing. popup_element_jquery_selector: '.eupopup' #You must have an HTML element matching this jQuery selector located somewhere in your HTML code. For example: <div class="eupopup"></div> The element can be empty. cookie_policy_page_id: false #If this is an integer, the "learn more" link in the popup box will take the user to this page. options: cookiePolicyUrl: "/cookie-policy" #This option is ignored if cookie_policy_page_id is not false. popupPosition: "top" colorStyle: "default" compactStyle: "false" popupTitle: "This website is using cookies" popupText: "We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we'll assume that you are happy to receive all cookies on this website." buttonContinueTitle: "Continue" buttonLearnmoreTitle: "Learn more" buttonLearnmoreOpenInNewWindow: "true" agreementExpiresInDays: 30 autoAcceptCookiePolicy: "false" htmlMarkup: "null"
4. 可选模板变量
您可以在任何模板中使用这些变量以实现附加功能。
- $CookiePolicyLink: 使用 'options.cookiePolicyUrl' 选项或 'cookie_policy_page_id' 选项配置的 YAML 配置中的 'cookiePolicyUrl' 选项来获取您已经配置的 cookie 政策页面的 URL 的简单方法。
- $DeleteAllCookiesLink: 您可以创建一个链接,例如
<a href="$DeleteAllCookiesLink">取消接受Cookies并删除现有Cookies</a>
。当用户点击此链接时,将删除由任何javascript库创建的所有Cookies,并且 cookie 法规弹出框将重新出现,通知用户她未接受接收Cookies。请注意,如果您在模板中使用此变量,将自动包含一个额外的JavaScript文件作为要求,这可能会略微增加页面加载时间。
未来计划
- 使管理员面板中配置
cookiePolicyURL
成为可能,通过在 SiteConfig 中选择一个页面。 - 也许有一个预定义的方式在用户接受接收Cookies后 之后 初始化 JavaScript 片段(使用 Cookies)。现在也是可能的,但这需要一些工作: http://www.wimagguc.com/2018/05/gdpr-compliance-with-the-jquery-eu-cookie-law-plugin/#gdpr_compliance
您有自己的想法吗?请通过 issues 告诉我! :) 欢迎Pull requests。
作者
原始 JavaScript 库: wimagguc/jquery-eu-cookie-law-popup。
SilverStripe 模块:Jarkko Linnanvirta jarkko@taitavasti.fi