protected function getCurrentPageNumber($query)
    {
        $currentPageNumber = $this->currentPageNumber;

        if (!$currentPageNumber && empty($this->searchTerm)) {
            // Restore the last visited page from the session if available.
            $currentPageNumber = $this->getSession('lastVisitedPage');
        }

        $currentPageNumber = intval($currentPageNumber);

        if ($currentPageNumber > 1) {
            $count = $query->count();

            // If the current page number is higher than the amount of available pages, go to the last available page
            if ($count <= (($currentPageNumber - 1) * $this->recordsPerPage)) {
                $currentPageNumber = ceil($count / $this->recordsPerPage);
            }
        }

        return $currentPageNumber;
    }
protected function getCurrentPageNumber($query)
    {
        $currentPageNumber = $this->currentPageNumber;

        if (!$currentPageNumber && empty($this->searchTerm)) {
            // Restore the last visited page from the session if available.
            $currentPageNumber = $this->getSession('lastVisitedPage');
        }

        $currentPageNumber = intval($currentPageNumber);

        if ($currentPageNumber > 1) {
            $count = $query->count();

            // If the current page number is higher than the amount of available pages, go to the last available page
            if ($count <= (($currentPageNumber - 1) * $this->recordsPerPage)) {
                $currentPageNumber = ceil($count / $this->recordsPerPage);
            }
        }

        return $currentPageNumber;
    }
protected function getCurrentPageNumber ( $ query ) { $ currentPageNumber = $ this -> currentPageNumber ; if ( ! $ currentPageNumber && empty ( $ this -> searchTerm ) ) { // Restore the last visited page from the session if available. $ currentPageNumber = $ this -> getSession ( 'lastVisitedPage' ) ; } $ currentPageNumber = intval ( $ currentPageNumber ) ; if ( $ currentPageNumber > 1 ) { $ count = $ query -> count ( ) ; // If the current page number is higher than the amount of available pages, go to the last available page if ( $ count <= ( ( $ currentPageNumber - 1 ) * $ this -> recordsPerPage ) ) { $ currentPageNumber = ceil ( $ count / $ this -> recordsPerPage ) ; } } return $ currentPageNumber ; }
Returns the current page number for the list.

This will override the current page number provided by the user if it is past the last page of available records.

@param object $query
@return int
Returns the current page number for the list .