quanzo / yii2-shortcode
Implementation shortcodes. Module for yii2
1.0.0
2019-08-31 14:40 UTC
Requires
- php: >=5.6
- quanzo/x51-shortcode: *
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2025-04-29 01:20:18 UTC
README
Installation
-
Copy to the folder with modules and connect autoload.php
-
Or use composer: add to the require section of the project
"quanzo/yii2-shortcode": "*"
orcomposer require "quanzo/yii2-shortcode"
-
Add to configuration
$config = [ 'bootstrap' => [ 'shortcode', ], 'modules' => [ 'shortcode' => [ 'class' => '\x51\yii2\modules\shortcode\Module', 'automatic' => false, // process content before output to browser 'exclude' => [ // Routes in which the use of shortcodes is prohibited. Use * and ? mask 'blocks/*', ], 'shortcodes' => [ 'url' => function ($arParams, $content = '') { // use [url path="/site/index"]main page[/url] if (!empty($arParams['path'])) { $arUrl = [ $arParams['path'] ]; foreach ($arParams as $name => $val) { if ($name != 0 || $name != 'path') { $arUrl[$name] = $val; } } $href = Url::to($arUrl); if ($content) { return Html::a($content, $href); } else { return $href; } } return ''; }, ] ], ] ];