Alphapager advanced
Total 11 items.
| # | Last Name | First Name | Born | Died |
|---|---|---|---|---|
| 1 | Varda | Agnès | 1928/05/30 | 2019/03/29 |
| 2 | Varèse | Edgar(d) | 1883/12/22 | 1965/11/06 |
| 3 | Vega | Suzanne | 1959/07/11 | — |
| 4 | Verhoeven | Paul | 1938/07/18 | — |
| 5 | Vermeer | Johannes | 1632/10/31 | 1675/12/15 |
| 6 | Verne | Jules | 1828/02/08 | 1905/03/24 |
| 7 | Vian | Boris | 1920/03/09 | 1959/06/23 |
| 8 | Vicious | Sid | 1957/05/10 | 1979/02/02 |
| 9 | Vinci | Leonardo da | 1452/03/28 | 1519/04/12 |
| 10 | Visconti | Luchino | 1906/11/02 | 1976/03/17 |
| 11 | Vrienten | Henny | 1948/07/27 | 2022/04/25 |
Yii2 Alphapager lets you do alphabetic paging in the Yii framework 2.0. On this page it is shown with some special settings.
The relevant code involved is something like this:
<?php
use sjaakp\alphapager\ActiveDataProvider;
use sjaakp\alphapager\AlphaPager;
$query = Person::find()->orderBy('last_name, first_name');
$dataProvider = new ActiveDataProvider([
'query' => $query,
'alphaAttribute' => 'last_name',
'alphaDigits' => 'compact', // one button for digits '0' - '9'
'alphaPages' => [
'P' => [
'label' => 'pq', // label button 'P' with 'pq'
'pattern' => [ '[PpQq]' ], // regular expression: include words starting with 'Q' under 'P'
],
'Q' => false, // suppress page 'Q'
'Z' => [
'label' => 'x-z', // label button 'Z' with 'x-z'
'pattern' => [ '[X-Zx-z]' ], // regular expression: include words starting with 'X' or 'Y' under 'Z'
],
'X' => false, // suppress page 'X'
'Y' => false, // suppress page 'Y'
],
'pagination' => false // switch off normal pagination
]);
?>
<?= AlphaPager::widget([
'dataProvider' => $dataProvider,
'preButtons' => [], // no 'all' button
'lowerCase' => true // buttons in lower case
]) ?>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'columns' => [
['class' => 'yii\grid\SerialColumn'],
'last_name:ntext',
'first_name:ntext',
'born:date',
'died:date',
],
]); ?>
A basic example is here.