Closed makroxyz closed 6 years ago
I assume this is part of a module which is implemented into a cms page as module block or as page type module.
Yes it is
Il 16 feb 2018 15:51, "Basil" notifications@github.com ha scritto:
I assume this is part of a module which is implemented into a cms page as module block or as page type module.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/luyadev/luya/issues/1771#issuecomment-366256232, or mute the thread https://github.com/notifications/unsubscribe-auth/AB-Vvb3qcvqGWARo9qiCtfrLVkSo731Tks5tVZYIgaJpZM4SIcC3 .
@makroxyz thank you for the report!
@makroxyz are you running the latest dev-master?
On my system it seem to work with the latest dev-master. Your example
<?= ListView::widget(['dataProvider' => $provider,
'itemView' => '_product',
'layout' => "<div class=\"text-right\">{pager}</div>\n<div class=\"row animated fadeInLeft\">{items}</div>\n<div class=\"text-right\">{pager}</div>",
'pager' => [
'class' => LinkPager::class,
'options' => ['class' => 'pagination pagination-sm'],
],
]); ?>
(i used the news module)
here a screenshot from the links generated from the pagination (the bottom one)
the example setup:
This is what the ActiveDataProvider looks like:
$provider = new ActiveDataProvider([
'query' => Article::find()->andWhere(['is_deleted' => false]),
'sort' => [
'defaultOrder' => $this->module->articleDefaultOrder,
],
'pagination' => [
'route' => $this->module->id,
'params' => ['page' => Yii::$app->request->get('page')],
'defaultPageSize' => $this->module->articleDefaultPageSize,
],
]);
I'm using latest dev-master
My ActiveDataProvider doesn't have pagination definition. Try to delete pagination definition in ActiveDataProvider and you'll see it will generate 2 different urls for top and bottom pager... and this is not good in my opinion.
The only workaround I found is:
$provider = new ActiveDataProvider([
....
'pagination' => [
'route' => $this->getRoute(),
],
]);
Hope it helps
ok, now i see the problem.
@makroxyz i pushed a fix which should fix the problem. Could you please try? Thanks
It works now! Thanx!
What steps will reproduce the problem?
in a view
What is the expected result?
The 2 pagers (top and bottom) should work in the same way
What do you get instead? (A Screenshot can help us a lot!)
Second pager has wrong urls inside button (cms/default)
The problem is: ListView renders a page for each item, so the render() method is called for every item.
This fires EVENT_BEFORE_RENDER/View::EVENT_AFTER_RENDER and ModuleReflection.php (rows 244, 253) switches controller at every event. So after the last item controller is switched to original, and the bottom pager creates urls with wrong controller.
Hope it helps