kunstmaan / cookie-bundle
Kunstmaan Cookie Bundle 提供一个 cookie 栏;详细的弹出窗口和类似页面,解释网站使用的每种类型的 cookie。
Requires
- php: ^8.1
- doctrine/orm: ^2.13
- kunstmaan/admin-bundle: ^7.0
- kunstmaan/adminlist-bundle: ^7.0
- kunstmaan/config-bundle: ^7.0
- kunstmaan/generator-bundle: ^7.0
- 7.x-dev
- 7.1.x-dev
- 7.1.1
- 7.1.0
- 7.1.0-alpha2
- 7.1.0-alpha1
- 7.0.x-dev
- 7.0.4
- 7.0.3
- 7.0.2
- 7.0.1
- 7.0.0
- 7.0.0-alpha1
- 6.x-dev
- 6.4.x-dev
- 6.4.2
- 6.4.1
- 6.4.0
- 6.4.0-alpha2
- 6.4.0-alpha1
- 6.3.x-dev
- 6.3.1
- 6.3.0
- 6.2.x-dev
- 6.2.5
- 6.2.4
- 6.2.3
- 6.2.2
- 6.2.1
- 6.2.0
- 6.1.x-dev
- 6.1.9
- 6.1.8
- 6.1.7
- 6.1.6
- 6.1.5
- 6.1.4
- 6.1.3
- 6.1.2
- 6.1.1
- 6.1.0
- 6.0.x-dev
- 6.0.6
- 6.0.5
- 6.0.4
- 6.0.3
- 6.0.2
- 6.0.1
- 6.0.0
- dev-master / 1.7.x-dev
- 1.7.0
- 1.6.x-dev
- 1.6.1
- 1.6.0
- 1.5.x-dev
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.x-dev
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.x-dev
- 1.3.1
- 1.3.0
- 1.2.x-dev
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2
- 1.1.x-dev
- 1.1.1
- 1.1
- 1.0.x-dev
- 1.0.1
- 1.0
This package is auto-updated.
Last update: 2024-09-14 17:45:40 UTC
README
Kunstmaan Cookie Bundle 提供一个 cookie 栏;详细的弹出窗口和类似页面,解释网站使用的每种类型的 cookie。
所有这些都能接受或拒绝某些 cookie。
原始贡献者
启用包
添加到 Appkernel.php
添加到 routing.yml
KunstmaanCookieBundle:
resource: "@KunstmaanCookieBundle/Resources/config/routing.yml"
prefix: /{_locale}/
requirements:
_locale: "%requiredlocales%"
查看cookie实现的两种方式
1: 登录到 CMS
2: 在设置 -> cookie 配置下启用 cookie 包
导入 cookie 包
在页面上显示 cookie
将以下块添加到您网站的首页布局中
{# Kuma Cookie Bar #}
{% block kumacookiebar %}
<kuma-cookie-bar></kuma-cookie-bar>
{% endblock %}
CSS: 第一种方法
通过将 legal.scss 文件导入项目的 vendors 文件夹中,应用所有 CSS。
@import "vendor/kunstmaan/cookie-bundle/src/Resources/ui/scss/legal";
CSS: 第二种方法
导入 Kunstmaan Cookie Bundle 变量和导入以覆盖。将以下路径的文件复制到您的项目文件夹中。
vendor/kunstmaan/cookie-bundle/Resources/ui/scss/config/_variables.scss vendor/kunstmaan/cookie-bundle/Resources/ui/scss/config/_legal-imports.scss
修改变量并注释导入以符合项目的样式。
JavaScript
通过 ES Module 模式
import '../../../../../../vendor/kunstmaan/cookie-bundle/bin/';
通过构建工具
您可以通过以下 URL 将编译版本包含在构建工具中 - 或直接在模板中:
vendor/kunstmaan/cookie-bundle/src/Resources/ui/bin/index.js
全局方法
CookieBundle 暴露了一些实用方法,您可以将它们包含在项目中。
import {getKmccCookies} from '<VENDOR_LOCATION>/kunstmaan/cookie-bundle/bin/'; // Returns the settings of all the cookies.
import {hasAllowedDatalayers} from '<VENDOR_LOCATION>/kunstmaan/cookie-bundle/bin/'; // Shorthand to check if you're allowed to use dataLayers in this
project.
import {asyncDomInitiator} from '<VENDOR_LOCATION/kunstmaan/cookie-bundle/bin/'; // This is to initialize async inserted Cookie Bundle Components. Expects 1 param: an object like the following: {nodeTree: <HTMLElement>}
这两种方法也适用于没有打包器的项目全局作用域
window.kmcc.getKmccCookies();
window.kmcc.hasAllowedDatalayers();
window.kmcc.asyncDomInitiator({
nodeTree: <HTMLElement>
});
命令
将 Cookiebar 资源复制到您的项目中
默认命令
php bin/console kuma:generate:legal --prefix foo_ --demosite
或者,如果您已经生成了文件并希望覆盖它们:php bin/console kuma:generate:legal --prefix will_ --demosite --overrideFiles
迁移
php bin/console doctrine:migrations:diff
php bin/console doctrine:migrations:migrate
生成固定值
php bin/console d:f:l --fixtures src/foo/AppBundle/DataFixtures/ORM/LegalGenerator/DefaultFixtures.php --append
将 optin 页面部分添加到您的表单页面中。
我们添加了一个额外的 LegalOptInPagePart,它像一个复选框,但还添加了直接链接到隐私政策的额外功能。
该页面部分将在您的包中生成,您必须将其包含在页面部分配置 yaml 文件中。
- { name: 'Opt In', class: Foo\WebsiteBundle\Entity\PageParts\LegalOptInPagePart }
轻松生成打开 cookie 模态链接
使用此片段,您可以在自定义位置(如页脚)轻松添加必要的链接到项目中。
{% if is_granted_for_cookie_bundle(app.request) %}
{% set legalLinks = ['legal_privacy_policy', 'legal_cookie_preferences', 'legal_contact'] %}
{% for internalName in legalLinks %}
{% set node = nodemenu.getNodeByInternalName(internalName) %}
{% if (node is not null) %}
-
<a data-target="{{ internalName }}" data-url="{{ path('kunstmaancookiebundle_legal_modal', {'internal_name': internalName}) }}"
class="sub-footer__info__link js-kmcc-extended-modal-button">
{{ node.title }}
</a>
{% endif %}
{% endfor %}
{% endif %}
覆盖翻译
如果您想覆盖 cookie 包的翻译,您需要在 config.yml 中添加以下配置,在现有的 kunstmaan_translator 配置之下。
kunstmaan_translator:
default_bundle: custom
bundles:
- KunstmaanCookieBundle
- YourOwnBundle
将访客类型添加到 Google Analytics
我们添加了将数据层推送到 Google Analytics 的可能性,以查看您网站的访客类型。已添加新的 Config 实体,您可以在此处添加客户端或内部 ip 地址。这些 ip 地址将在请求时进行检查,并将数据层推送。
如果您想使用此功能,请阅读 Config Bundle 文档以进行设置。设置完成后,请将以下片段添加到您的 config.yml 中。
kunstmaan_config:
entities:
- Kunstmaan\CookieBundle\Entity\CookieConfig
以下输入字段应添加到您的 layout.html.twig 中。您可以在 kuma-cookie-bar 元素下方添加。
<input type="hidden" value="{{ get_visitor_type(app.request) }}" id="kmcc-visitor-type"/>
在添加 cookies/types 或更改需要新 cookie 约束的内容时,增加版本号。
在 cookie 配置中,有一个可用的版本号。此版本号可以在 CMS 中增加。
贡献
我们热爱贡献!如果您正在提交拉取请求,请遵循提交拉取请求指南