Skip to content

TomaIvanovTomov/yii2-slider

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

STILL IN DEVELOPMENT!!!!

yii2-slider

Yii2 slider is an extension with Owl Carousel 2.3.3 slider in it.
The slider has multilingual behaviour for title and description on each slide.

Installation

composer require tomaivanovtomov/yii2-revolution "^1.1.3"

Configuration

Add the Module class to `config.php`:
'modules' => [
    ....
    'user' => [
        'class' => 'tomaivanovtomov\slider\Module',
    ],
    ....
],

Add migrations

Create the two tables - `slide` and `slideLang`
php yii migrate/up --migrationPath=@vendor/tomaivanovtomov/yii2-slider/migrations

Register assets

Register revolution assets on top of your `layout\main.php`
\tomaivanovtomov\revolution\Assets::register($this);

Image path is set to www.example.com/frontend/web .

Usage

Call the widget and set the preferable options.
height - height of the slider.
slides - Images like an array of objects.

    public static function getSliderImages()
    {
        return \tomaivanovtomov\slider\models\Slide::find()
            ->joinWith('translation')
            ->select(['slide.id', 'slideLang.title', 'slide.filename'])
            ->where('slideLang.language=:lang', [':lang' => Yii::$app->language])
            ->all();
    } 
    echo \tomaivanovtomov\slider\widgets\Slider::widget([
        'slides' => \tomaivanovtomov\slider\models\Slide::getSliderImages(),
        'height' => 400,
        'options' => [
            'items' => 1
        ]
    ]);

All slider options can be seen at

https://owlcarousel2.github.io/OwlCarousel2/docs/api-options.html

Multilingual part

Copy these line in `params.php`:
'language-information' => [
    'BG' => [
        'title' => 'Български',
        'extension' => 'bg',
    ],
    'EN' => [
        'title' => 'English',
        'extension' => 'en',
    ],
],
'languageDefault' => 'bg'

This portion of code is linked with the multilingual model functionality. You can override the model and adapt it to your needs.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published