public function InfiniteScroll::query in Views Infinite Scroll 8
Modify the query for paging
This is called during the build phase and can directly modify the query.
Overrides SqlBase::query
File
- src/
Plugin/ views/ pager/ InfiniteScroll.php, line 133
Class
- InfiniteScroll
- Views pager plugin to handle infinite scrolling.
Namespace
Drupal\views_infinite_scroll\Plugin\views\pagerCode
public function query() {
// Run the pant method which is sufficient if we're on the first page.
parent::query();
// If configured, for pages beyond the first, we want to show all items up
// to the current page.
if ($this->options['views_infinite_scroll']['initially_load_all_pages'] && !\Drupal::request()
->isXmlHttpRequest() && $this->current_page > 0) {
$limit = ($this->current_page + 1) * $this->options['items_per_page'];
$offset = $this->options['offset'];
$this->view->query
->setLimit($limit);
$this->view->query
->setOffset($offset);
}
}