Swiper demo
Konrad Zuse dies
| ID | 202 |
|---|---|
| Date | 1995/12/18 |
| Description | Builder of the first electromechanical computer, the Z2 |
| Symbol | far fa-tombstone |
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',
// ...
],
])
...
?>