prokhonenkov/yii2-banners-system
Composer 安装命令:
composer require prokhonenkov/yii2-banners-system
包简介
The system of banners
关键字:
README 文档
README
This extension helps to place banners on pages of a site and manage them.
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require prokhonenkov/yii2-banners-system
or add
"prokhonenkov/yii2-banners-system": "*"
to the require section of your composer.json file.
Migrations
Run the following command
php yii migrate --migrationPath=@prokhonenkov/bannerssystem/migrations --interactive=0
Configuration
Add module declaration to your config file for web config:
<?php return [ // ... your config 'modules' => [ 'bannersSystem' => [ 'class' => \prokhonenkov\bannerssystem\BannersSystem::class, 'administratorPermissionName' => 'admin', //admin role 'uploadDir' => '@webroot/media/banners-system', 'uploadUrl' => '@web/media/banners-system', ], ], 'bootstrap' => [ 'bannersSystem' // add module id to bootstrap for proper aliases and url routes binding ] ];
Also, you can override layout and view files:
<?php return [ // ... your config 'modules' => [ 'bannersSystem' => [ 'class' => \prokhonenkov\bannerssystem\BannersSystem::class, 'administratorPermissionName' => 'admin', //admin role 'uploadDir' => '@webroot/media/banners-system', 'uploadUrl' => '@web/media/banners-system', 'layout' => '@alias/views/layouts/main', 'views' => [ 'banner' => [ 'index' => '@path/index', 'update' => '@path/update', 'create' => '@path/create', 'view' => '@path/view', ], 'area' => [ 'index' => '@path/index', 'update' => '@path/update', 'create' => '@path/create', 'view' => '@path/view', ] ], ], ], ];
Usage
Put this code in your desired controller:
public function behaviors() { return [ 'banner-system' => [ 'class' => \prokhonenkov\bannerssystem\behaviors\BannerSystemBehavior::class ] ]; }
Then, create a banner zone and banner in the admin panel.
Put this code in your desired view file in the desired place:
<?= \prokhonenkov\bannerssystem\BannerZone::getInstance()->setZoneById(BANNER_ZONE_ID);?>
统计信息
- 总下载量: 101
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2019-03-25