All Projects → bizley → yii2-cookiemonster

bizley / yii2-cookiemonster

Licence: BSD-3-Clause license
Yii extension to manage cookie warning

Programming Languages

PHP
23972 projects - #3 most used programming language
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to yii2-cookiemonster

Yii2 Fullcalendar
Widget for Yii Framework 2.0 to use FullCalendar
Stars: ✭ 5 (-68.75%)
Mutual labels:  widget, yii2
Yii2 Date Picker Widget
Bootstrap DatePicker Widget for Yii2
Stars: ✭ 128 (+700%)
Mutual labels:  widget, yii2
Yii2 Fotorama Widget
Fotorama image gallery widget for yii2
Stars: ✭ 18 (+12.5%)
Mutual labels:  widget, yii2
yii2-multi-select-widget
Bootstrap MultiSelect and MultiSelect Listbox widgets for Yii2
Stars: ✭ 45 (+181.25%)
Mutual labels:  widget, yii2
yii2-content-tools
ContentTools editor implementation for Yii 2
Stars: ✭ 79 (+393.75%)
Mutual labels:  widget, yii2
yii2-number
A number format mask control and input for Yii2 Framework
Stars: ✭ 22 (+37.5%)
Mutual labels:  widget, yii2
Yii2 Sortable Widgets
🍨 Rubaxa/Sortable for Yii2
Stars: ✭ 54 (+237.5%)
Mutual labels:  widget, yii2
Yii2 Quill
Yii 2 implementation of Quill, modern WYSIWYG editor
Stars: ✭ 52 (+225%)
Mutual labels:  widget, yii2
yii2-switch-widget
Bootstrap Switch Widget for Yii2
Stars: ✭ 17 (+6.25%)
Mutual labels:  widget, yii2
yii2-grid-view-library
Highly enhanced GridView widget and grid components for Yii2
Stars: ✭ 57 (+256.25%)
Mutual labels:  widget, yii2
yii2-time-down-counter
Widget for yii2, to start count down timer with a lot of options, This widget build dependence of timeDownCounter JS library
Stars: ✭ 15 (-6.25%)
Mutual labels:  widget, yii2
yii2-widget-cropbox
This widget allows crop image before upload to server and send informations about crop in JSON format.
Stars: ✭ 90 (+462.5%)
Mutual labels:  widget, yii2
yii2-google-analytics
Google Analytics Universal tracking widget.
Stars: ✭ 14 (-12.5%)
Mutual labels:  widget, yii2
yii2-notification-wrapper
Yii2-notification-wrapper module renders a message from session flash (with ajax, pjax support and etc.) through Growl, Noty, Toastr and more libraries
Stars: ✭ 78 (+387.5%)
Mutual labels:  widget, yii2
Yii2 Imperavi Widget
Imperavi Redactor widget for Yii 2
Stars: ✭ 250 (+1462.5%)
Mutual labels:  widget, yii2
yii2-datetime-widgets
Datetime widgets for Yii2
Stars: ✭ 22 (+37.5%)
Mutual labels:  widget, yii2
yii2-highcharts-widget
HighCharts Js Widget for Yii2
Stars: ✭ 40 (+150%)
Mutual labels:  widget, yii2
yii2-yandex-market-yml
Yii2 module for automatically generation Yandex.Market YML
Stars: ✭ 14 (-12.5%)
Mutual labels:  yii2
yii2-behaviors
Collection of useful behaviors for Yii Framework 2.0
Stars: ✭ 25 (+56.25%)
Mutual labels:  yii2
EasyMoney-Widgets
The widgets (EditText and TextView) for support of money requirements like currency, number formatting, comma formatting etc.
Stars: ✭ 91 (+468.75%)
Mutual labels:  widget

yii2-cookiemonster

Yii 2 extension to manage cookie warning

Latest Stable Version Total Downloads License Mutation testing badge

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' => [
        '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 - array CSS class and styles and HTML options for div
  • content - array warning and button message
  • cookie - array cookie options
  • mode - string widget layout selection
  • params - mixed user's parameters to pass to the custom widget layout

box options

  • addButtonStyle - array list of button CSS style options to be added or replaced with new values i.e. 'padding-right' => '20px', 'font-weight' => 'bold'
  • addInnerStyle - array list of inner div CSS style options to be added or replaced with new values
  • addOuterStyle - array list of outer div CSS style options to be added or replaced with new values
  • buttonHtmlOptions - array list of button HTML options to be added (except style and class)
  • classButton - string button class or classes (separated by spaces), default 'CookieMonsterOk'
  • classInner - string inner div class or classes (separated by spaces)
  • classOuter - string outer div class or classes (separated by spaces), default 'CookieMonsterBox'
  • innerHtmlOptions - array list of inner div HTML options to be added (except style and class)
  • outerHtmlOptions - array list of outer div HTML options to be added (except style and class)
  • replaceButtonStyle - array list of button CSS style options to be replaced with new values or removed i.e. 'margin-left' => '10px', 'font-size' => false
  • replaceInnerStyle - array list of inner div CSS style options to be replaced with new values or removed
  • replaceOuterStyle - array list of outer div CSS style options to be replaced with new values or removed
  • setButtonStyle - array list of button CSS style options to be set replacing the default ones
  • setInnerStyle - array list of inner div CSS style options to be set replacing the default ones
  • setOuterStyle - array list of outer div CSS style options to be set replacing the default ones
  • view - string path to the custom view (required if $mode is set to 'custom'), for views outside the widget folder use alias path i.e. '@app/views/cookie'

content options

  • buttonMessage - string button original message as in Yii::t() $message, default 'I understand'
  • buttonParams - array parameters to be applied to the buttonMessage as in Yii::t() $params, default array()
  • category - string message category as in Yii::t() $category, default 'app'
  • language - string target language as in Yii::t() $language, default null
  • mainMessage - string main original message as in Yii::t() $message, default '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.'
  • mainParams - array parameters to be applied to the mainMessage as in Yii::t() $params, default array()

cookie options

  • domain - string domain name for the cookie, default host portion of the current document location
  • expires - integer number of days this cookie will be valid for, default 30
  • max-age - integer max cookie age in seconds
  • path - string path for the cookie, default '/'
  • secure - boolean whether cookie should be transmitted over secure protocol as https, default false
  • sameSite - string 'lax' (default), 'strict', or 'none'

mode possible values

  • bottom - bottom strip
  • box - bottom right box
  • custom - custom mode defined by user (requires box[view] to be set)
  • top - top strip, default

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>

Yii 1.1 version

You can find Yii 1.1 version at https://github.com/bizley/Yii-CookieMonster

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].