Closed chuprik closed 9 years ago
Thanks. But frankly, I disagree. You can set any other digits just as well by using DataProvider::alphaPages and AlphaPager::postButtons.
Sjaak Priester
sjaak@sjaakpriester.nl
Van: Constantine Chuprik [mailto:notifications@github.com] Verzonden: zondag 21 juni 2015 16:53 Aan: sjaakp/yii2-alphapager Onderwerp: [yii2-alphapager] Custom digits (#2)
Hi! These changes allow to use any digits (I needed letters of the Russian alphabet) to generate a pager links.
Usage:
$dataProvider = new ActiveDataProvider([ 'query' => News::find(), 'alphaAttribute' => 'title', 'alphaDigits' => ['А', 'Б', 'В'], ]);
Looks this:
You can view, comment on, or merge this pull request online at:
https://github.com/sjaakp/yii2-alphapager/pull/2
Commit Summary
File Changes
Patch Links:
— Reply to this email directly or view it on GitHub https://github.com/sjaakp/yii2-alphapager/pull/2 . https://github.com/notifications/beacon/AFU71ji-EGC9c5kcrvW0AFl9aKqGU928ks5oVsdRgaJpZM4FIVBv.gif
But it's not right. Look the your code:
$pages = array_merge($this->preButtons, range('A', 'Z'), $digs, $this->postButtons);
range('A', 'Z')
is definitely will be added to the pages array. but it is not always necessary for example — I need Russian digits only. I could override run()
but why? I think it should be customizable.
As an example, here is how you might make buttons for Roman numerals, showing ‘normal’ numeric pages:
$dataProvider = new ActiveDataProvider([ 'query' => Person::find(), 'alphaAttribute' => 'last_name', 'alphaPages' => [ 'd1' => [ // keys should start with alpha character 'label' => 'I', 'pattern' => '1' ], 'd2' => [ 'label' => 'II', 'pattern' => '2' ], // .. 'd7' => [ 'label' => 'VII', 'pattern' => '7' ], // .. 'd9' => [ 'label' => 'IX', 'pattern' => '9' ], ] ]);
<?= AlphaPager::widget([
'dataProvider' => $dataProvider,
'postButtons' => array_map(function($v) { return 'd' . $v; }, range(1, 9))
]) ?>
It’s a little bit involved, I agree, but not impossible.
Sjaak Priester
sjaak@sjaakpriester.nl
Van: Constantine Chuprik [mailto:notifications@github.com] Verzonden: maandag 22 juni 2015 10:59 Aan: sjaakp/yii2-alphapager CC: Sjaak Priester Onderwerp: Re: [yii2-alphapager] Custom digits (#2)
but it's not right look the your code:
$pages = array_merge($this->preButtons, range('A', 'Z'), $digs, $this->postButtons);
range('A', 'Z') is definitely will be added to the array. but it is not always necessary for example — I need Russian digits only. I could override run() but why? I think it should be customizable.
— Reply to this email directly or view it on GitHub https://github.com/sjaakp/yii2-alphapager/pull/2#issuecomment-114044855 . https://github.com/notifications/beacon/AFU71k_KtQjPFyynPyFEfjtkMt4p8C3Uks5oV8XTgaJpZM4FIVBv.gif
I just checked your option. It isn't help me :) Look result:
It's result of copy/paste your example.
I mean I want to do pager like that:
And my pull request solve this problem. Current pager must display all English digits (range('A', 'Z')
). Sometimes it is not required.
Sorry, I misunderstood you completely. What you call ‘digits’, I call ‘alphabetic characters’, hence the confusion. English isn’t my native language.
Anyway, I merged your pull request.
Sjaak Priester
sjaak@sjaakpriester.nl
Van: Constantine Chuprik [mailto:notifications@github.com] Verzonden: maandag 22 juni 2015 17:23 Aan: sjaakp/yii2-alphapager CC: Sjaak Priester Onderwerp: Re: [yii2-alphapager] Custom digits (#2)
I just checked your option. It isn't help me :) Look result:
It's result of copy/paste your example.
I mean I want to do pager like that:
And my pull request solve this problem. Current pager must display all English digits (range('A', 'Z')). Sometimes it is not required.
— Reply to this email directly or view it on GitHub https://github.com/sjaakp/yii2-alphapager/pull/2#issuecomment-114152856 . https://github.com/notifications/beacon/AFU71hg0MqUHMPIOQJM6pb2bF_5GjIoqks5oWB-7gaJpZM4FIVBv.gif
no problem. English isn't my native language too. I call it 'digits' because you call in the your code :)
thanks for the merge :)
Hi! These changes allow to use any digits (I needed letters of the Russian alphabet) to generate a pager links.
Usage:
Looks this: