black-lamp / yii2-slider
Module for adding image slider to site across dashboard
Installs: 180
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 4
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- black-lamp/yii2-text-editor: 1.*.*
- bower-asset/slick-carousel: 1.6.0
- yiisoft/yii2: ^2.0.4
- yiisoft/yii2-bootstrap: ^2.0.0
Requires (Dev)
This package is not auto-updated.
Last update: 2024-12-21 21:25:37 UTC
README
Module for adding the image slider to site across dashboard and append it to view with widget help. This extension uses Slick slider.
Installation
Run command
composer require black-lamp/yii2-slider
or add
"black-lamp/yii2-slider": "*"
to the require section of your composer.json.
Applying migrations
yii migrate --migrationPath=@vendor/black-lamp/yii2-slider/src/common/migrations
Add module to application config
Module for backend
'modules' => [ // ... 'slider' => [ 'class' => bl\slider\backend\Module::class ] ]
Module configuration properties
Using
You should use the widget for adding the slider to the page
<?= bl\slider\frontend\widgets\SliderWidget::widget([ 'sliderKey' => 'home-page-slider' ]) ?>
Widget configuration properties
Also you can append this slider to your Active Record model
Configuration
Add behavior to your Active Record model
use yii\db\ActiveRecord; /** * @property string $sliderKey * @property SliderContent[] $sliderContent */ class Article extends ActiveRecord { public function behaviors() { return [ // ... 'slider' => [ 'class' => \bl\slider\common\behaviors\SliderBehavior::class ], ]; } }
Using
$article = new Article(); $article->sliderKey = "article-slider"; $slide_one = new SliderContent(); $slide_one->content = "img/slider/slider-1.jpg"; $slide_one->position = 1; $slide_two = new SliderContent(); $slide_two->content = "img/slider/slider-2.jpg"; $slide_two->position = 2; // slide N... $article->sliderContent = $slide_one; $article->sliderContent = $slide_two; // or $article->sliderContent = [$slide_one, $slide_two]; $article->save();