yii2-cookiemonster ¶
- What is it for?
- Requirements
- Installation
- Usage
- Configuration
- `box` options
- `content` options
- `cookie` options
- `mode` possible values
- Default layouts
- GitHub repo
- Yii 1.1 version
Yii 2 extension to manage cookie warning
What is it for? ¶
In 2009, the European Union sought new regulations as part of an "e-privacy" directive, seeing cookies as a potential threat to privacy, because users often don't know they are being tracked. This extension adds the information about cookies for the Yii website.
Requirements ¶
Yii 2
Installation ¶
Get it through composer by adding the package to your composer.json:
{
"require": {
"bizley/cookiemonster": "*"
}
}
Or run `
composer require bizley/cookiemonster`
.
Usage ¶
Add this code in your main template file just before `
<?php $this->endBody() ?>`
<?= \bizley\cookiemonster\CookieMonster::widget() ?>
This will render widget with all default options (and 'top' layout). If you want to configure it add options array.
<?= \bizley\cookiemonster\CookieMonster::widget([/* options here */]) ?>
All options (and options' options) are described below. For example if you want to use custom message on the button and use 'bottom' layout set:
<?= \bizley\cookiemonster\CookieMonster::widget([
'content' => array(
'buttonMessage' => 'OK', // instead of default 'I understand'
),
'mode' => 'bottom'
]); ?>
Configuration ¶
You can set widget options by passing array to the widget() method with the following keys:
`
box`
options ¶
`
content`
options ¶
`
cookie`
options ¶
`
mode`
possible values ¶
Default layouts ¶
bottom ¶
<div style="display:none;z-index:10000;position:fixed;background-color:#fff;font-size:12px;color:#000;bottom:0;left:0;width:100%;box-shadow:0 -2px 2px #000" class="CookieMonsterBox">
<div style="margin:10px" class="">
We use cookies on our websites to help us offer you the best online experience. By continuing to use our website, you are agreeing to our use of cookies. Alternatively, you can manage them in your browser settings.<button style="margin-left:10px" class="CookieMonsterOk" type="button">I understand</button>
</div>
</div>
box ¶
<div style="display:none;z-index:10000;position:fixed;background-color:#fff;font-size:12px;color:#000;bottom:20px;right:20px;width:300px;box-shadow:-2px 2px 2px #000;border-radius:10px" class="CookieMonsterBox">
<div style="margin:10px" class="">
We use cookies on our websites to help us offer you the best online experience. By continuing to use our website, you are agreeing to our use of cookies. Alternatively, you can manage them in your browser settings.<button style="margin-left:10px" class="CookieMonsterOk" type="button">I understand</button>
</div>
</div>
top ¶
<div style="display:none;z-index:10000;position:fixed;background-color:#fff;font-size:12px;color:#000;top:0;left:0;width:100%;box-shadow:0 2px 2px #000" class="CookieMonsterBox">
<div style="margin:10px" class="">
We use cookies on our websites to help us offer you the best online experience. By continuing to use our website, you are agreeing to our use of cookies. Alternatively, you can manage them in your browser settings.<button style="margin-left:10px" class="CookieMonsterOk" type="button">I understand</button>
</div>
</div>
GitHub repo ¶
https://github.com/bizley/yii2-cookiemonster
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.