quanzo / yii2-shortcode
Implementation shortcodes. Module for yii2
Installs: 4
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/quanzo/yii2-shortcode
Requires
- php: >=5.6
- quanzo/x51-shortcode: *
- yiisoft/yii2: ~2.0.0
This package is auto-updated.
Last update: 2025-09-29 02:36:37 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 ''; }, ] ], ] ];