Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexeevdv/yii2-shortcodes
https://github.com/alexeevdv/yii2-shortcodes
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/alexeevdv/yii2-shortcodes
- Owner: alexeevdv
- License: mit
- Created: 2018-04-20T08:40:28.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-01T20:52:48.000Z (over 5 years ago)
- Last Synced: 2024-09-04T08:21:13.101Z (4 months ago)
- Language: PHP
- Size: 13.7 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
yii2-shortcodes
=================
[![Build Status](https://travis-ci.org/alexeevdv/yii2-shortcodes.svg?branch=master)](https://travis-ci.org/alexeevdv/yii2-shortcodes)
[![codecov](https://codecov.io/gh/alexeevdv/yii2-shortcodes/branch/master/graph/badge.svg)](https://codecov.io/gh/alexeevdv/yii2-shortcodes)
![PHP 5.6](https://img.shields.io/badge/PHP-5.6-green.svg)
![PHP 7.0](https://img.shields.io/badge/PHP-7.0-green.svg)
![PHP 7.1](https://img.shields.io/badge/PHP-7.1-green.svg)
![PHP 7.2](https://img.shields.io/badge/PHP-7.2-green.svg)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]
```