Use offset in count

Created on 27 April 2022, over 2 years ago

Problem/Motivation

We need to use entity_pager with a paginated view.
It might be an edge use case, but we basically need to have prev/next links only for a given page of the view (links should stop when reaching the end of the current page).

To do this, we call EntityPagerFactory::get() manually on our paginated view.
Everything works correctly, except the count which does not handle the offset correctly.

Steps to reproduce

Create a view with 100 results, which displays 50 results per page.

Build a block with this code:

Views::getView('foo');
$view->setCurrentPage(1);
$links = $this->pagerFactory->get($view, ['relationship' => []])->getLinks();

Display it on the third node of the page.
The count is "3 of 100" instead of "53 of 100".

Proposed resolution

EntityPager::getCount() should add the offset to the count.

🐛 Bug report
Status

Needs work

Component

Code

Created by

🇫🇷France prudloff Lille

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024