Advertisement
yesamarcos

Simple Bootstrap Pagination Library - Codeigniter 3

May 1st, 2017
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.17 KB | None | 0 0
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2.  
  3. class Mygination
  4. {
  5.     protected $ci;
  6.  
  7.     public function __construct()
  8.     {
  9.         $this->ci=& get_instance();
  10.         $this->ci->load->library('pagination');
  11.     }
  12.  
  13.     /**
  14.      * Prepare to render Pagination with Bootstrap
  15.      * @return [type] [description]
  16.      */
  17.     public function render(){
  18.         return $this->bootstrap();
  19.         /*
  20.             <!-- CODE OUTSIDE LIBRARY TO USE render (Controller) -->
  21.  
  22.             // Load render in controller
  23.             $configs = $this->mygination->render();
  24.             // Count rows
  25.             $get = $this->casamentos_model->getAllCasamentos();
  26.  
  27.             // Setup parameters for controller/method pagination
  28.             $configs['base_url'] = base_url("casamentos/reais");
  29.             $configs['total_rows'] = $get->num_rows();
  30.             $configs['per_page'] = 6;
  31.             $inicio = (!$this->uri->segment(3)) ? 0 : $this->uri->segment(3);
  32.  
  33.             // Render pagination on ending
  34.             $this->pagination->initialize($configs);
  35.             $data['pagination'] = $this->pagination->create_links();  
  36.         */
  37.     }
  38.  
  39.     /**
  40.      * Setup configs to load pagination with Bootstrap
  41.      * @return [type] [description]
  42.      */
  43.     private function bootstrap(){
  44.  
  45.         // Config for bootstrap pagination class integration
  46.         $config['full_tag_open'] = '<ul class="pagination">';
  47.         $config['full_tag_close'] = '</ul>';
  48.         $config['first_link'] = false;
  49.         $config['last_link'] = false;
  50.         $config['first_tag_open'] = '<li>';
  51.         $config['first_tag_close'] = '</li>';
  52.         $config['prev_link'] = '&laquo';
  53.         $config['prev_tag_open'] = '<li class="prev">';
  54.         $config['prev_tag_close'] = '</li>';
  55.         $config['next_link'] = '&raquo';
  56.         $config['next_tag_open'] = '<li>';
  57.         $config['next_tag_close'] = '</li>';
  58.         $config['last_tag_open'] = '<li>';
  59.         $config['last_tag_close'] = '</li>';
  60.         $config['cur_tag_open'] = '<li class="active"><a href="#">';
  61.         $config['cur_tag_close'] = '</a></li>';
  62.         $config['num_tag_open'] = '<li>';
  63.         $config['num_tag_close'] = '</li>';
  64.  
  65.         return $config;
  66.     }
  67. }
  68. /* End of file Mygination.php */
  69. /* Location: ./application/libraries/Mygination.php */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement