Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/black-lamp/yii2-slider
Module for adding sliders to site across dashboard
https://github.com/black-lamp/yii2-slider
black-lamp php yii-extension yii2
Last synced: about 2 months ago
JSON representation
Module for adding sliders to site across dashboard
- Host: GitHub
- URL: https://github.com/black-lamp/yii2-slider
- Owner: black-lamp
- License: bsd-3-clause
- Created: 2016-10-21T11:31:36.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-09-10T14:07:20.000Z (over 7 years ago)
- Last Synced: 2024-04-03T21:21:29.524Z (9 months ago)
- Topics: black-lamp, php, yii-extension, yii2
- Language: PHP
- Homepage:
- Size: 77.1 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
Slider module for Yii2
======================
Module for adding the image slider to site across dashboard and append it to view with widget help.
This extension uses [Slick slider](http://kenwheeler.github.io/slick/).[![Build Status](https://travis-ci.org/black-lamp/yii2-slider.svg?branch=master)](https://travis-ci.org/black-lamp/yii2-slider)
[![Latest Stable Version](https://poser.pugx.org/black-lamp/yii2-slider/v/stable)](https://packagist.org/packages/black-lamp/yii2-slider)
[![Latest Unstable Version](https://poser.pugx.org/black-lamp/yii2-slider/v/unstable)](https://packagist.org/packages/black-lamp/yii2-slider)
[![License](https://poser.pugx.org/black-lamp/yii2-slider/license)](https://packagist.org/packages/black-lamp/yii2-slider)Installation
------------
#### Run command
```
composer require black-lamp/yii2-slider
```
or add
```json
"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
```php
'modules' => [
// ...
'slider' => [
'class' => bl\slider\backend\Module::class
]
]
```
#### Module configuration properties| Option | Description | Type | Default |
|---|---|---|---|
|imagesRoot|Path to images catalog in web folder (need for uploading images to the server across dashboard)|string|@frontend/web/img/slider|
|urlSeparator|Separator for getting url to image from image path|string|web|
|imagePrefix|Prefix for uploaded images (need for uploading images to the server across dashboard)|string|slider|Using
-----
#### You should use the widget for adding the slider to the page
```php
= bl\slider\frontend\widgets\SliderWidget::widget([
'sliderKey' => 'home-page-slider'
]) ?>
```
#### Widget configuration properties| Option | Description | Type | Default |
|---|---|---|---|
|sliderKey|Unique slider key|string|-|
|imagePattern|Pattern for image|string|\\|
|slickSliderOptions|Slider plugin configuration array.For more information read official [Slick slider](http://kenwheeler.github.io/slick/) documentation.|array|['slidesToShow' => '3', 'slidesToScroll' => '1', 'autoplay' => 'true', 'autoplaySpeed' => '2000']|Also you can append this slider to your Active Record model
-----------------------------------------------------------
#### Configuration
Add behavior to your Active Record model
```php
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
```php
$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();
```