Class Pagination
Set the total number of records, number of displaying items per page, then render the page numbers with links.
This class support to render pages in these styles.
First Previous Next Last
Previous Next
First Previous 1 2 3 4 [5] 6 7 8 9 Next Last
Previous 1 2 3 4 [5] 6 7 8 9 Next
1 2 3 4 [5] 6 7 8 9
First Previous 1 2 ... 4 [5] 6 ... 8 9 Next Last
Previous 1 2 ... 4 [5] 6 ... 8 9 Next
1 2 ... 4 [5] 6 ... 8 9
First Previous 4 [5] 6 ... 8 9 Next Last
Previous 4 [5] 6 ... 8 9 Next
4 [5] 6 ... 8 9
First Previous 1 2 ... 4 [5] 6 Next Last
Previous 1 2 ... 4 [5] 6 Next
1 2 ... 4 [5] 6
Or any custom styles that you can build on your own.
public
|
|
public
|
|
public
|
|
public
string
|
#
createLinks( string $result_string = 'Displaying page :current_page_number_displaying of :total_pages<br>:pagination' )
Create pagination links and return the html data. |
public
array
|
#
getPaginationData( )
Generate the pagination data for render in HTML. |
public
string
|
$base_url
(Required property.) The URL for use when generate page numbers with links. Set the position where page numbers will be appears as URI segment or query string with %PAGENUMBER% placeholder. |
|
public
integer
|
$total_records
(Required property.) The total number of records. This means "all" records by conditions with out the "LIMIT" or slices commands. |
|
public
integer
|
$items_per_page
The number of items that will be displaying per page. Such as number of articles to display in each page. |
#
10
|
public
string
|
$page_number_type
The page number type. The value can be start_num or page_num. Start number or start_num. (eg. page number value will be 0, 10, 20, 30, ...) Page number or page_num. (eg. page number value will be 1, 2, 3, 4, ...) |
#
'start_num'
|
public
integer
|
$page_number_value
(Required property.) The current page number value. This class cannot detect current page number automatically because of dynamic styles of URL. So, you have to manually set its value to this property. |
|
public
string
|
$overall_tag_open
The overall tag open. It will be place at the very beginning of displaying page numbers. |
#
''
|
public
string
|
$overall_tag_close
The overall tag close. It will be place at the very end of displaying page numbers. |
#
''
|
public
mixed
|
$first_page_text
The link text of the paginate that will go to the first page. Set to false to not displaying first page link. |
#
'« First'
|
public
boolean
|
$first_page_always_show
If you are at first page the first page link will not show if you set this value to false, if you set to true it will be always show the first page link. |
#
false
|
public
string
|
$first_tag_open
The first page tag open. If you set to display first page, this will be placed before link to the first page. |
#
' '
|
public
string
|
$first_tag_close
The first page tag close. If you set to display first page, this will be placed after link to the first page. |
#
' '
|
public
mixed
|
$last_page_text
The link text of the paginate that will go to the last page. Set to false to not displaying last page link. |
#
'Last »'
|
public
boolean
|
$last_page_always_show
If you are at last page the last page link will not show if you set this value to false, if you set to true it will be always show the last page link. |
#
false
|
public
string
|
$last_tag_open
The last page tag open. If you set to display last page, this will be placed before link to the last page. |
#
' '
|
public
string
|
$last_tag_close
The last page tag close. If you set to display last page, this will be placed after link to the last page. |
#
' '
|
public
mixed
|
$next_page_text
The link text of the paginate that will go to the next page. Set to false to not displaying next page link. |
#
'Next ›'
|
public
boolean
|
$next_page_always_show
If you are at last page the next page link will not show if you set this value to false, if you set to true it will be always show the next page link. |
#
false
|
public
string
|
$next_tag_open
The next page tag open. If you set to display next page, this will be placed before link to the next page. |
#
' '
|
public
string
|
$next_tag_close
The next page tag close. If you set to display next page, this will be placed after link to the next page. |
#
' '
|
public
mixed
|
$previous_page_text
The link text of the paginate that will go to the previous page. Set to false to not displaying previous page link. |
#
'‹ Previous'
|
public
boolean
|
$previous_page_always_show
If you are at first page the previous page link will not show if you set this value to false, if you set to true it will be always show the previous page link. |
#
false
|
public
string
|
$previous_tag_open
The previous page tag open. If you set to display previous page, this will be placed before link to the previous page. |
#
' '
|
public
string
|
$previous_tag_close
The previous page tag close. If you set to display previous page, this will be placed after link to the previous page. |
#
' '
|
public
boolean
|
$current_page_link
Display current link at current page. Set to true to display, false not to display. |
#
false
|
public
string
|
$current_tag_open
The current page tag open. If you set to display current page, this will be placed before link to the current page. |
#
' <strong>'
|
public
string
|
$current_tag_close
The current page tag close. If you set to display current page, this will be placed after link to the current page. |
#
'</strong> '
|
public
boolean
|
$number_display
Display the page numbers or not. Set to true to display, false not to display. |
#
true
|
public
string
|
$number_tag_open
The page number tag open. If you set to display page number, this will be placed before link to the page number. |
#
' '
|
public
string
|
$number_tag_close
The page number tag close. If you set to display page number, this will be placed after link to the page number. |
#
' '
|
public
integer
|
$number_adjacent_pages
The number of adjacent pages before and after the current page. |
#
5
|
public
boolean
|
$unavailable_display
Display unavailable page (...) or not. Set to true to display, false to not display. |
#
false
|
public
string
|
$unavailable_text
The unavailable page text. Basically it is something to show that there are pages between these range such as 3 dots text. (...) |
#
'…'
|
public
string
|
$unavailable_tag_open
The unavailable page tag open. If you set to display unavailable page, this will be placed before unavailable page (...). |
#
' '
|
public
string
|
$unavailable_tag_close
The unavailable page tag close. If you set to display unavailable page, this will be placed after unavailable page (...). |
#
' '
|
public
mixed
|
$unavailable_before
Number of pages to display before first unavailable page. Set number as integer or set to false to not display the pages before unavailable. |
#
2
|
public
mixed
|
$unavailable_after
Number of pages to display after last unavailable page. Set number as integer or set to false to not display the pages after unavailable. |
#
2
|
protected
array
|
$temp_properties
Temporary property for store the original properties. |
|
protected
integer
|
$total_pages
Total pages that was calculated from total records and items per page. This is for use in programatic only. |