Swiper demo
W3C founded
ID | 150 |
---|---|
Date | 1994/10/01 |
Description | World Wide Web Consortium |
Symbol | far fa-code |
This is a demonstration of Yii2-swiper for the Yii framework 2.0. It allows the user to move to neighbouring records by means of clicking, touch swiping, or using the left and right arrow keys.
Model code
<?php use sjaakp\swiper\PrevNextBehavior; class Event extends \yii\db\ActiveRecord { public static function tableName() { return 'event'; } public function behaviors() { return [ [ 'class' => PrevNextBehavior::class, 'attribute' => 'date', ] // ]; } // ... }
View code
<?php use yii\widgets\DetailView; use sjaakp\swiper\Swiper; ?> ... <?= Swiper::widget([ 'model' => $model, 'labelAttribute' => 'title', 'shortLabelAttribute' => 'date', 'titleAttribute' => 'description', 'url' => 'swiper', ]) ?> ... <?= DetailView::widget([ 'model' => $model, 'attributes' => [ 'id', // ... ], ]) ... ?>