alexeevdv/yii2-shortcodes

Installs: 3 081

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 1

Open Issues: 2

Type:yii2-extension

0.1.1 2018-04-20 14:37 UTC

This package is auto-updated.

Last update: 2024-10-29 04:53:32 UTC


README

Build Status codecov PHP 5.6 PHP 7.0 PHP 7.1 PHP 7.2

Yii2 behavior for rendering widgets with WordPress style shortcodes.

Installation

The preferred way to install this extension is through composer.

Either run

$ php composer.phar require alexeevdv/yii2-shortcodes "~0.1.0"

or add

"alexeevdv/yii2-shortcodes": "~0.1.0"

to the require section of your composer.json file.

Configuration

use alexeevdv\yii\shortcodes\ShortcodeBehavior;

//...
'components' => [
    //...
    'view' => [
        'as shortcodeBehavior' => ShortcodeBehavior::class,
        'map' => [
            'feedback' => \frontend\widgets\ContactForm::class,
            'gallery' => [ 
                'class' => \frontend\widgets\GalleryWidget::class,
                'theme' => 'dark',
            ],
        ],
    ],
    //...
],
//...

Usage

namespace frontend\widgets;

class GalleryWidget extends \yii\base\Widget
{
    public $id;
    
    public $theme;
    
    public function run()
    {
        // render your gallery here using $id and $theme
    }
}
//Anywhere in your layouts, views or rendered content:

[gallery id=413]