andrewdanilov/yii2-cookies-agreement

Sticky footer panel widget, which lets your visitors to accept user policy agreement.

Installs: 56

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 1

Forks: 1

Open Issues: 0

Language:JavaScript

Type:yii2-extension

1.0.3 2025-04-11 16:45 UTC

This package is auto-updated.

Last update: 2025-04-11 16:48:24 UTC


README

Sticky footer panel widget, which lets your visitors to accept user policy agreement.

Installation

The preferred way to install this extension is through composer.

Either run

composer require andrewdanilov/yii2-cookies-agreement "~1.0.0"

or add

"andrewdanilov/yii2-cookies-agreement": "~1.0.0"

to the require section of your composer.json file.

Usage

Place widget at any place of desired layout:

<?php
echo CookiesAgreement::widget([
    'message' => 'By continuing to use our site, you consent to the processing of cookies and other user data, in accordance with this notice on their use. If you do not agree to these terms, please disable cookies. Learn more about <a href="{url}">privacy policy</a>.', // optional
    'url' => 'https://example.com/agreement', // optional, use if {url} tag presents in message property
]);

For message you can use i18n if you want. Adjust config file as needed:

<?php
'components' => [
    // ...
    'i18n' => [
        'translations' => [
            'app*' => [
                'class' => 'yii\i18n\PhpMessageSource',
                //'basePath' => '@app/messages',
                //'sourceLanguage' => 'en-US',
                'fileMap' => [
                    'app' => 'app.php',
                ],
            ],
        ],
    ],
],

Then add needed translation to app/messages/ru-RU/app.php:

<?php
/**
* Translation map for en-US
*/
return [
    'By continuing to use our site, you consent to the processing of cookies and other user data, in accordance with this notice on their use. If you do not agree to these terms, please disable cookies. Learn more about <a href="{url}">privacy policy</a>.'
        => 'Продолжая использовать наш сайт, вы даете согласие на обработку файлов Cookies и других пользовательских данных, в соответствии с настоящим уведомлением об их использовании. Если вы не согласны с этими условиями, пожалуйста, отключите файлы cookies. Подробнее о <a href="{url}">политике конфиденциальности</a>.',
];

Read i18n manual for more details.