How to customize CodeIgniter pagination on Bootstrap design

Pagination is one concept used for web applications. Wherever we have a bulk of data and need to show them, then it allows you to navigate from page to page, at that time we require pagination.

CodeIgniter is a open-source web framework that is used for rapid web development. CodeIgniter follows the MVC (Model-View-Controller) architectural pattern. It is noted for its speed compared to other PHP web frameworks.

Have a look, how I solve How To Customize CodeIgniter Pagination Design problem.

Step 1.

Create a file pagination.php in application/config/ .

Step 2.

Copy the following code and paste in pagination.php

$config['base_url']   = ''; // The page we are linking to
$config['prefix']   = ''; // A custom prefix added to the path.
$config['suffix']   = ''; // A custom suffix added to the path.

$config['total_rows']   =  0; // Total number of items (database results)
$config['per_page']   = 10; // Max number of items you want shown per page
$config['num_links']   =  2; // Number of "digit" links to show before/after the currently viewed page
$config['cur_page']   =  0; // The current page being viewed
$config['use_page_numbers']     = FALSE; // Use page number for segment instead of offset
$config['first_link']   = '‹ First';
$config['next_link']   = '<span aria-hidden="true"><i class="fas fa-chevron-right"></i></span>';
$config['prev_link']   = '<span aria-hidden="true"><i class="fas fa-chevron-left"></i></span>';
$config['last_link']   = 'Last ›';
$config['uri_segment']      = 3;
$config['full_tag_open']  = '<ul class="pagination pagination-sm justify-content-center g-2">';
$config['full_tag_close']  = '</ul>';
$config['first_tag_open']  = '<li class="page-link">';
$config['first_tag_close']     = '</li>';
$config['last_tag_open']  = '<li class='page-link'>';
$config['last_tag_close']  = '</li>';
$config['first_url']   = ''; // Alternative URL for the First Page.
$config['cur_tag_open']      = '<li class="page-item active"><span class="page-link">';
$config['cur_tag_close']  = '</a></li>';
$config['next_tag_open']  = '<li class="page-link">';
$config['next_tag_close']  = '</li>';
$config['prev_tag_open']  = '<li class="page-link">';
$config['prev_tag_close']  = '</li>';
$config['num_tag_open']      = '<li class="page-link">';
$config['num_tag_close']  = '</li>';
$config['page_query_string'] = FALSE;
$config['query_string_segment'] = 'per_page';
$config['display_pages']  = TRUE;
$config['anchor_class']      = '';

Thanks for reading the complete post. Hope you have got the concept. You can share your views in the space provided below and get in touch with us.

RH Suman
RH Suman
Articles: 64

Newsletter Updates

Enter your email address below to subscribe to our newsletter

Leave a Reply