stupidkitty/banner

为 Yii2 定制的横幅模块

安装: 241

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 1

分支: 0

开放问题: 0

类型:yii2-extension

3.1 2021-06-11 14:16 UTC

This package is auto-updated.

Last update: 2024-09-16 19:15:51 UTC


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']) ?>