You are here

public function jcarouselPager::query in jCarousel 8.5

Same name and namespace in other branches
  1. 8.4 src/Plugin/views/pager/jcarouselPager.php \Drupal\jcarousel\Plugin\views\pager\jcarouselPager::query()

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/jcarouselPager.php, line 38
Contains \Drupal\views\Plugin\views\pager\jcarouselPager.

Class

jcarouselPager
The plugin to handle full pager.

Namespace

Drupal\jcarousel\Plugin\views\pager

Code

public function query() {
  parent::query();

  // Don't query for the next page if we have a pager that has a limited
  // amount of pages.
  if ($this
    ->getItemsPerPage() > 0 && (empty($this->options['total_pages']) || $this
    ->getCurrentPage() < $this->options['total_pages'])) {

    // Increase the items in the query in order to be able to find out whether
    // there is another page.
    $limit = $this->view->query
      ->getLimit();
    $limit += 1;
    $this->view->query
      ->setLimit($limit);
  }
}