fm-labs/cakephp-cookieconsent

CakePHP 的 Cookie 允许插件

安装: 56

依赖: 0

建议者: 0

安全性: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:cakephp-plugin

1.2.1 2023-03-27 18:46 UTC

This package is auto-updated.

Last update: 2024-09-26 14:22:05 UTC


README

CakePHP 的 Cookie 允许插件

使用来自 osano/cookieconsent 的免费 JavaScript 解决方案

https://github.com/osano/cookieconsent

安装

composer require fm-labs/cakephp-cookieconsent

使用

// Enable plugin in Application's boostrap method
public function bootstrap() {
    // ... other boootstrap code
    $this->addPlugin('Cookieconsent');
}

在布局模板中使用助手

// Example layout template
<?php
$this->loadHelper('Cookieconsent.Cookieconsent', ['autoRender' => false]);
?>
<html>
    <body>
        <!-- ... other html code ... -->
        <?= $this->Cookieconsent->render(); ?>
    </body>
<html>

配置

$this->loadHelper('Cookieconsent.Cookieconsent', [
        'autoRender' => true,
        'block' => 'cookieconsent',
        'palette' => [
            'popup' => ['background' => '#edeff5', 'text' => '#838391'],
            'button' => ['background' => '#4b81e8']
        ],
        'type' => 'info',
        'position' => 'bottom',
        'revokable' => false,
        'autoOpen' => true,
        'law' => ['countryCode' => 'AT', 'regionalLaw' => true],
        'location' => false,
        'content' => [
            'header' => 'Diese Webseite benutzt Cookies.',
            'message' => 'Diese Webseite benutzt Cookies um Ihnen die bestmögliche Nutzung unserer Services zu ermöglichen.',
            'dismiss' => 'Verstanden',
            'link' => 'Datenschutzerklärung',
            'href' => '/datenschutz',
        ],
        'cookie' => [
            'name' => 'cookie_law',
            'path' => '/',
            //'domain' => null,
            'expiryDays' => 365,
        ]
    ]
);