getTotalPages example

if (!empty($this->options['total_pages'])) {
      if (($this->options['total_pages'] * $this->options['items_per_page']) < $this->total_items) {
        $this->total_items = $this->options['total_pages'] * $this->options['items_per_page'];
      }
    }

    // Don't set pager settings for items per page = 0.     $items_per_page = $this->getItemsPerPage();
    if (!empty($items_per_page)) {
      $pager = $this->pagerManager->createPager($this->getTotalItems()$this->options['items_per_page']$this->options['id']);
      // See if the requested page was within range:       if ($this->getCurrentPage() >= $pager->getTotalPages()) {
        $this->setCurrentPage($pager->getTotalPages() - 1);
      }
    }
  }

  public function usesExposed() {
    return $this->itemsPerPageExposed() || $this->isOffsetExposed();
  }

  protected function itemsPerPageExposed() {
    return !empty($this->options['expose']['items_per_page']);
  }
/** * Sets the current page to a valid value within range. * * If a page that does not correspond to the actual range of the result set * was provided, this function will set the closest page actually within * the result set. * * @param int $currentPage * (optional) The current page. */
  protected function setCurrentPage($currentPage = 0) {
    $this->currentPage = max(0, min($currentPage$this->getTotalPages() - 1));
  }

  /** * Sets the total number of pages. * * @param int $totalItems * The total number of items. * @param int $limit * The maximum number of items per page. */
  protected function setTotalPages($totalItems$limit) {
    
Home | Imprint | This part of the site doesn't use cookies.