jordanbeattie / craftcms-cookie-consent
Google Tag Manager 的同意管理器
1.0.1
2024-01-23 11:29 UTC
Requires
- craftcms/cms: ^3.0.0|^4.0.0
Requires (Dev)
- craftcms/rector: dev-main
This package is auto-updated.
Last update: 2024-09-23 13:07:59 UTC
README
此插件将在页面右下角添加一个弹出窗口,通知用户该网站使用cookie,并允许他们启用/禁用广告和统计分析cookie。
需求
项目必须使用 AlpineJS、TailwindCSS 和 CraftCMS。
安装
将以下钩子添加到您的 <head>
元素中。
{% hook 'cookie-consent' %}
将以下内容添加到您的 tailwind.config.js
中
content: [
...
'./vendor/jordanbeattie/craftcms-cookie-consent/**/*.twig'
],
自定义
样式
您可以使用以下ID来针对弹出窗口中的单个元素
CookieConsent
CookieConsent__Wrapper
CookieConsent__DefaultContent
CookieConsent__Headline
CookieConsent__Copy
CookieConsent__Buttons
CookieConsent__AcceptButtons
CookieConsent__AcceptButton
CookieConsent__NecessaryOnlyButton
CookieConsent__Moreutton
CookieConsent__DetailContent
CookieConsent__Options
CookieConsent__Necessary
CookieConsent__Analytics
CookieConsent__Advertisement
CookieConsent__PolicyLink
CookieConsent__DetailButtons
CookieConsent__SubmitButton
CookieConsent__LessButton
内容
弹出窗口中的大部分内容都可以通过配置文件进行自定义。运行以下命令将在您的 config
目录中创建一个 cookie-consent.php
文件,您可以进行自定义。
php craft cookie-consent/config
用法
在您的Twig模板中,您可以使用以下函数来检查用户是否已接受分析或广告cookie。
craft.cookieConsent.getConsent()