diff options
-rw-r--r-- | user_guide_src/source/libraries/pagination.rst | 105 |
1 files changed, 57 insertions, 48 deletions
diff --git a/user_guide_src/source/libraries/pagination.rst b/user_guide_src/source/libraries/pagination.rst index d9d3f5092..06627cfeb 100644 --- a/user_guide_src/source/libraries/pagination.rst +++ b/user_guide_src/source/libraries/pagination.rst @@ -15,7 +15,7 @@ Example ******* Here is a simple example showing how to create pagination in one of your -:doc:`controller <../general/controllers>` functions:: +:doc:`controller <../general/controllers>` methods:: $this->load->library('pagination'); @@ -30,8 +30,8 @@ Here is a simple example showing how to create pagination in one of your Notes ===== -The $config array contains your configuration variables. It is passed to -the $this->pagination->initialize function as shown above. Although +The ``$config`` array contains your configuration variables. It is passed to +the ``$this->pagination->initialize()`` method as shown above. Although there are some twenty items you can configure, at minimum you need the three shown. Here is a description of what those items represent: @@ -46,7 +46,7 @@ three shown. Here is a description of what those items represent: - **per_page** The number of items you intend to show per page. In the above example, you would be showing 20 items per page. -The create_links() function returns an empty string when there is no +The ``create_links()`` method returns an empty string when there is no pagination to show. Setting preferences in a config file @@ -54,9 +54,9 @@ Setting preferences in a config file If you prefer not to set preferences using the above method, you can instead put them into a config file. Simply create a new file called -pagination.php, add the $config array in that file. Then save the file -in: config/pagination.php and it will be used automatically. You will -NOT need to use the $this->pagination->initialize function if you save +pagination.php, add the ``$config`` array in that file. Then save the file +in *application/config/pagination.php* and it will be used automatically. +You will NOT need to use ``$this->pagination->initialize()`` if you save your preferences in a config file. ************************** @@ -67,14 +67,14 @@ The following is a list of all the preferences you can pass to the initialization function to tailor the display. $config['uri_segment'] = 3; -============================ +=========================== The pagination function automatically determines which segment of your URI contains the page number. If you need something different you can specify it. $config['num_links'] = 2; -========================== +========================= The number of "digit" links you would like before and after the selected page number. For example, the number 2 will place two digits on either @@ -92,25 +92,19 @@ $config['page_query_string'] = TRUE; By default, the pagination library assume you are using :doc:`URI Segments <../general/urls>`, and constructs your links something -like - -:: +like:: http://example.com/index.php/test/page/20 - -If you have $config['enable_query_strings'] set to TRUE your links +If you have ``$config['enable_query_strings']`` set to TRUE your links will automatically be re-written using Query Strings. This option can -also be explictly set. Using $config['page_query_string'] set to TRUE, -the pagination link will become. - -:: +also be explictly set. Using ``$config['page_query_string']`` set to TRUE, +the pagination link will become:: http://example.com/index.php?c=test&m=page&per_page=20 - Note that "per_page" is the default query string passed, however can be -configured using $config['query_string_segment'] = 'your_string' +configured using ``$config['query_string_segment'] = 'your_string'`` $config['reuse_query_string'] = FALSE; ====================================== @@ -118,9 +112,7 @@ $config['reuse_query_string'] = FALSE; By default your Query String arguments (nothing to do with other query string options) will be ignored. Setting this config to TRUE will add existing query string arguments back into the -URL after the URI segment and before the suffix - -:: +URL after the URI segment and before the suffix.:: http://example.com/index.php/test/page/20?query=search%term @@ -128,13 +120,13 @@ This helps you mix together normal :doc:`URI Segments <../general/urls>` as well as query string arguments, which until 3.0 was not possible. $config['prefix'] = ''; -================================== +======================= A custom prefix added to the path. The prefix value will be right before the offset segment. $config['suffix'] = ''; -================================== +======================= A custom suffix added to the path. The sufix value will be right after the offset segment. @@ -144,15 +136,15 @@ Adding Enclosing Markup *********************** If you would like to surround the entire pagination with some markup you -can do it with these two prefs: +can do it with these two preferences: $config['full_tag_open'] = '<p>'; -=================================== +================================= The opening tag placed on the left side of the entire result. $config['full_tag_close'] = '</p>'; -===================================== +=================================== The closing tag placed on the right side of the entire result. @@ -161,18 +153,18 @@ Customizing the First Link ************************** $config['first_link'] = 'First'; -================================= +================================ The text you would like shown in the "first" link on the left. If you do not want this link rendered, you can set its value to FALSE. $config['first_tag_open'] = '<div>'; -====================================== +==================================== The opening tag for the "first" link. $config['first_tag_close'] = '</div>'; -======================================== +====================================== The closing tag for the "first" link. @@ -181,18 +173,18 @@ Customizing the Last Link ************************* $config['last_link'] = 'Last'; -=============================== +============================== The text you would like shown in the "last" link on the right. If you do not want this link rendered, you can set its value to FALSE. $config['last_tag_open'] = '<div>'; -===================================== +=================================== The opening tag for the "last" link. $config['last_tag_close'] = '</div>'; -======================================= +===================================== The closing tag for the "last" link. @@ -201,18 +193,18 @@ Customizing the "Next" Link *************************** $config['next_link'] = '>'; -=============================== +============================== The text you would like shown in the "next" page link. If you do not want this link rendered, you can set its value to FALSE. $config['next_tag_open'] = '<div>'; -===================================== +=================================== The opening tag for the "next" link. $config['next_tag_close'] = '</div>'; -======================================= +===================================== The closing tag for the "next" link. @@ -221,18 +213,18 @@ Customizing the "Previous" Link ******************************* $config['prev_link'] = '<'; -=============================== +============================== The text you would like shown in the "previous" page link. If you do not want this link rendered, you can set its value to FALSE. $config['prev_tag_open'] = '<div>'; -===================================== +=================================== The opening tag for the "previous" link. $config['prev_tag_close'] = '</div>'; -======================================= +===================================== The closing tag for the "previous" link. @@ -241,12 +233,12 @@ Customizing the "Current Page" Link *********************************** $config['cur_tag_open'] = '<b>'; -================================== +================================ The opening tag for the "current" link. $config['cur_tag_close'] = '</b>'; -==================================== +================================== The closing tag for the "current" link. @@ -255,12 +247,12 @@ Customizing the "Digit" Link **************************** $config['num_tag_open'] = '<div>'; -==================================== +================================== The opening tag for the "digit" link. $config['num_tag_close'] = '</div>'; -====================================== +==================================== The closing tag for the "digit" link. @@ -280,9 +272,7 @@ Adding attributes to anchors If you want to add an extra attribute to be added to every link rendered by the pagination class, you can set them as key/value pairs in the -"attributes" config - -:: +"attributes" config:: // Produces: class="myclass" $config['attributes'] = array('class' => 'myclass'); @@ -300,4 +290,23 @@ you can pass boolean FALSE as a regular attribute :: - $config['attributes']['rel'] = FALSE;
\ No newline at end of file + $config['attributes']['rel'] = FALSE; + +*************** +Class Reference +*************** + +.. class:: CI_Pagination + + .. method:: initialize([$params = array()]) + + :param array $params: Configuration parameters + :returns: void + + Initializes the Pagination class with your preferred options. + + .. method:: create_links() + + :returns: string + + Returns a "pagination" bar, containing the generated links or an empty string if there's just a single page.
\ No newline at end of file |