stupidkitty / banner
为 Yii2 定制的横幅模块
3.1
2021-06-11 14:16 UTC
Requires
- php: >=7.4
- yiisoft/yii2: ~2.0.38
README
Yii2 横幅模块
应用配置模块
'modules' => [
'banner' => [
'class' => SK\BannerModule\Module::class,
],
],
'container' => [
'singletons' => [
'SK\BannerModule\Banner' => [
'class' => \SK\BannerModule\Banner::class,
'templatesPath' => '@app/views/banners' // path for ad spots templates
]
]
]
迁移
config:
'controllerMap' => [
'migrate' => [
'class' => yii\console\controllers\MigrateController::class,
'migrationNamespaces' => [],
'migrationPath' => [
'@vendor/stupidkitty/banner/src/Migration',
],
],
],
或 composer
"scripts": {
"post-update-cmd": [
"yes | php yii migrate --migrationPath=@vendor/stupidkitty/banner/src/Migration"
],
"post-install-cmd": [
"yes | php yii migrate --migrationPath=@vendor/stupidkitty/banner/src/Migration"
]
}
用法
在模板中
<?php
use SK\BannerModule\Banner;
//...
// single
<?= Banner::show('banner.name') ?>
// or multiple
<?= Banner::show(['banner.first', 'banner.second']) ?>
// Spot template. Template should exists.
<?= Banner::show(['banner.first', 'banner.second'], ['template' => 'default']) ?>