bkc-media / twill-cookie-consent
一个基于cookie的twill包
v0.9.3-beta
2023-04-03 08:35 UTC
Requires
- php: ^8.0
- area17/twill: ^3.0
- laravel/framework: ^8|^9
This package is auto-updated.
Last update: 2024-09-09 11:12:20 UTC
README
本包提供了一个简单的方法,通过在CMS中添加基于用户偏好的cookie脚本,来将cookie同意功能添加到您的Twill 3x项目中。
需求
- PHP: ^8.0
- area17/twill: ^3.0
- Laravel: ^8|^9
安装
您可以通过composer安装此包
composer require bkc-media/twill-cookie-consent
发布资产以包含必要的javascript和css文件
php artisan vendor:publish --provider="BKCmedia\TwillCookieConsent\TwillCookieConsentServiceProvider" --tag="twill-cookie-consent-assets" --force
可选地发布配置文件
php artisan vendor:publish --provider="BKCmedia\TwillCookieConsent\TwillCookieConsentServiceProvider" --tag="twill-cookie-consent-config"
可选地发布语言文件
php artisan vendor:publish --provider="BKCmedia\TwillCookieConsent\TwillCookieConsentServiceProvider" --tag="twill-cookie-consent-translations"
发布的配置文件内容如下
return [ /* * The cookie name in which we store which cookie id's the user has consented to. */ 'cookie_name' => 'tcc_cookie_consent', /* * Set the cookie duration in minutes. Default is 60 * 24 * 365. */ 'cookie_lifetime' => 60 * 24 * 365, /* * Set primary color for cookie consent accept all buttons, default is green. */ 'primary_color' => '#65A30D', ];
运行迁移以添加twill cookie单例
php artisan migrate
用法
迁移后,您可以通过访问CMS中的cookie模块来添加cookie同意内容。添加cookie同意横幅描述和简介设置内容。使用块编辑器添加cookie类别,并在块内重复添加每个位置(头部、主体或页脚)的cookie信息和必要脚本。
将cookie同意横幅添加到您的app.blade.php文件或任何其他布局文件中
@include('twill-cookie-consent::components.cookie-consent')
根据提供商的脚本,在app.blade.php文件或任何其他布局文件中的正确位置添加以下内容
@include('twill-cookie-consent::components.head-scripts') @include('twill-cookie-consent::components.body-scripts') @include('twill-cookie-consent::components.footer-scripts')
根据用户偏好,脚本将添加到页面中的正确位置。