2017 © Pedro Peláez
 

yii2-extension yii2-shortcodes

image

alexeevdv/yii2-shortcodes

  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 40 % Grown

The README.md

yii2-shortcodes

Build Status codecov PHP 5.6 PHP 7.0 PHP 7.1 PHP 7.2, (*1)

Yii2 behavior for rendering widgets with WordPress style shortcodes., (*2)

Installation

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

Either run, (*4)

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

or add, (*5)

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

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

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]

The Versions