2017 © Pedro Peláez
 

yii2-extension yii2-cookie-button

Widget to store 0/1 in a cookie for Yii2 Framework

image

dmstr/yii2-cookie-button

Widget to store 0/1 in a cookie for Yii2 Framework

  • Friday, February 17, 2017
  • by schmunk
  • Repository
  • 7 Watchers
  • 4 Stars
  • 6,319 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 13 % Grown

The README.md

Yii 2 Cookie Button

Yii 2 Cookie Button based on "Twitter Bootstrap" Button or ButtonGroup. Widget to store 0/1 in a cookie for Yii2 Framework.
Add and remove cookies via javascript, with help of carhartl / jquery-cookie plugin., (*1)

Usage

Single button (default)

    $button = CookieButton::widget([
        'label' => FA::icon(FA::_EYE),
        'encodeLabel' => false,
        'toggleClass' => 'btn-primary',
        'cookieName' => 'Key-or-Name',
        'cookieValue' => 'on',
        'cookieOptions' => [
            'path' => '/',
            'http' => true,
            'expires' => strtotime('1 week')
        ],
        'options' => [
            'class' => 'btn-primary',
        ]
    ]);

Switch button

echo CookieButton::widget([
    'label' => ['On', 'Off'],           // String for default button, array for switch button
    'toggleClass' => 'btn-primary',     // Only needed if button type is switch
    'cookieName' => 'Key-or-Name',
    'cookieValue' => 'on',
    'options' => [
        'id' => 'cookieSwitchBtn',      // The button id
        'class' => 'btn-xs'             // Default button class
    ],
    'cookieOptions' => [
        'options' => [                  // 'options' are optional
            'expires' => 365,           // Define lifetime of the cookie.
                                        // Value can be a Number which will be interpreted as days
                                        // from time of creation or a Date object.
                                        // If omitted, the cookie becomes a session cookie.
            'path' => '/',              // Define the path where the cookie is valid.
                                        // By default the path of the cookie is the path of the page
                                        //where the cookie was created
                                        //(standard browser behavior).
            'domain' => 'example.com',  // Define the domain where the cookie is valid.
                                        // Default: domain of page where the cookie was created.
            'secure' => true            // If true, the cookie transmission requires a secure protocol (https).
                                        // Default: false.
        ]
    ]
]);

Installation

The preferred way to install this extension is through composer., (*2)

Add repository url to the required section of your composer.json file., (*3)

"repositories": [
    {
        "type": "git",
        "url": "https://github.com/dmstr/yii2-cookie-button.git"
    }
],

Either run, (*4)

php composer.phar require dmstr/yii2-cookie-button "*"

or add, (*5)

"dmstr/yii2-cookie-button": "*"

to the required section of your composer.json file., (*6)

The Versions

17/02 2017

dev-master

9999999-dev https://github.com/dmstr/yii2-cookie-button

Widget to store 0/1 in a cookie for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

by Marc Mautz

extension yii2 cms

17/02 2017

0.2.0

0.2.0.0 https://github.com/dmstr/yii2-cookie-button

Widget to store 0/1 in a cookie for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

by Marc Mautz

extension yii2 cms

05/09 2014

0.1.3

0.1.3.0 https://github.com/dmstr/yii2-cookie-button

Widget to store 0/1 in a cookie for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

by Marc Mautz

extension yii2 cms

04/09 2014

0.1.2

0.1.2.0 https://github.com/dmstr/yii2-cookie-button

Widget to store 0/1 in a cookie for Yii2 Framework

  Sources   Download

BSD-3-Clause

The Requires

 

by Marc Mautz

extension yii2 cms