Alphapager advanced
Total 20 items.
# | Last Name | First Name | Born | Died |
---|---|---|---|---|
1 | Adjani | Isabelle | 1955/06/27 | — |
2 | Adler | Charlie | 1957/02/20 | — |
3 | Albee | Edward | 1928/03/12 | 2016/09/16 |
4 | Aldrin | Buzz | 1930/01/20 | — |
5 | Ali | Muhammad | 1942/01/17 | 2016/06/03 |
6 | Allen | Woody | 1935/12/01 | — |
7 | Anderson | Gerry | 1929/04/14 | 2012/12/26 |
8 | Anderson | Laurie | 1947/06/05 | — |
9 | Andriessen | Louis | 1939/06/06 | 2021/07/01 |
10 | Antonioni | Michelangelo | 1912/09/29 | 2007/07/30 |
11 | Apollinaire | Guillaume | 1880/08/26 | 1918/11/09 |
12 | Appel | Karel | 1921/04/25 | 2006/05/03 |
13 | Aragon | Louis | 1897/10/03 | 1982/12/23 |
14 | Araki | Nobuyoshi | 1940/05/25 | — |
15 | Armstrong | Louis | 1901/08/04 | 1971/07/06 |
16 | Armstrong | Neil | 1930/08/05 | 2012/08/25 |
17 | Arp | Hans | 1887/09/16 | 1966/06/07 |
18 | Asimow | Isaac | 1920/01/02 | 1992/04/06 |
19 | Attenborough | David | 1926/05/08 | — |
20 | Aznavour | Charles | 1924/05/22 | 2018/10/01 |
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.