1. Go to this page and download the library: Download sjaakp/yii2-swiper library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
sjaakp / yii2-swiper example snippets
use sjaakp\swiper\PrevNextBehavior;
class Event extends \yii\db\ActiveRecord
{
// ...
public function behaviors()
{
return [
[
'class' => PrevNextBehavior::class,
'attribute' => 'date',
]
];
}
// ...
}
#### Swiper ####
This is a [`Widget`](https://www.yiiframework.com/doc/api/2.0/yii-base-widget),
rendering buttons to the previous and next page (if available). It also implements
the code to handle touch swiping and keyboard input. Its **$model** property should be set to an instance
of an `ActiveRecord` having **PrevNextBehavior**.
**Swiper**'s other properties are:
- **$labelAttribute** `string` Name of the attribute providing the label text for the
buttons. Must be set.
- **$shortLabelAttribute** `null|string` Name of the attribute providing the
short label text for the buttons. Optional. The short label appears when the screen
width is smaller than the value indicated by **$breakpoint**. Default: `null` (no short labels).
- **$titleAttribute** `null|string` Name of the attribute providing the
popup title text for the buttons. Optional. If `null` (default) the title text will
be the same as the label text.
- **$breakpoint** `string` The [Bootstrap 4 breakpoint](https://getbootstrap.com/docs/4.4/layout/overview/#responsive-breakpoints)
defining when short labels will appear. Default: `'sm'`.
- **$url** `string` The base URL of the button links. Default: `'view'`.
- **$swipeId** `null|string` The HTML-id of the element sensible to touch swiping.
If `null` (default) it is the `<body>` element.
- **$options** `array` HTML options for the surrounding `<nav>` element.
- **$registerLinkTags** `bool` Whether to register link tags in the HTML header
for previous and next page. Default: `false`, to avoid conflicts with other widgets.
In a view file, say `event\view`, **Swiper** could be employed along these lines:
use sjaakp\swiper\Swiper
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.