stupidkitty/banner

Banner module for Yii2

Installs: 241

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

Type:yii2-extension

3.1 2021-06-11 14:16 UTC

This package is auto-updated.

Last update: 2024-04-16 18:15:48 UTC


README

Yii2 banners module

App configure module

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

Migrations

config:
'controllerMap' => [
    'migrate' => [
        'class' => yii\console\controllers\MigrateController::class,
        'migrationNamespaces' => [],
        'migrationPath' => [
            '@vendor/stupidkitty/banner/src/Migration',
        ],
    ],
],

or 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"
    ]
}

Usage

In template:

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