https://github.com/alexeevdv/yii2-shortcodes
https://github.com/alexeevdv/yii2-shortcodes
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/alexeevdv/yii2-shortcodes
- Owner: alexeevdv
- License: mit
- Created: 2018-04-20T08:40:28.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2019-06-01T20:52:48.000Z (about 6 years ago)
- Last Synced: 2025-04-30T08:57:51.909Z (2 months ago)
- Language: PHP
- Size: 13.7 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
yii2-shortcodes
=================
[](https://travis-ci.org/alexeevdv/yii2-shortcodes)
[](https://codecov.io/gh/alexeevdv/yii2-shortcodes)



Yii2 behavior for rendering widgets with WordPress style shortcodes.
## Installation
The preferred way to install this extension is through [composer](https://getcomposer.org/download/).
Either run
```bash
$ 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
```php
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
```php
namespace frontend\widgets;class GalleryWidget extends \yii\base\Widget
{
public $id;
public $theme;
public function run()
{
// render your gallery here using $id and $theme
}
}
``````php
//Anywhere in your layouts, views or rendered content:[gallery id=413]
```