1

It so nightmare when using pagination on codeigniter. It work to move another page when click next or number after. But, the 'cur_tag_open' is not move. It still in first link of pagination. So let say, I clicked 3 on [1] [2] [3] , the class active still in one not in three. I can not find the solution of this problem, and this is my code :

CONTROLLER

class Control_direksi extends CI_Controller {
public function index() {
    $this->show();
}

public function show() {

    /** ======================================================= Inisialisasi table 1 =========================================================* */
    $start_row = $this->uri->segment(4);
    $per_page = 2;
    if (trim($start_row) == '') {
        $start_row = 0;
    };

    $total_rows = $this->model_request->hitungRequestMasukMD();

    $this->load->library('pagination');
    if ($total_rows != 0) {
        $config['base_url'] = base_url() . 'direksi/control_direksi/show/';
        $config['total_rows'] = $total_rows;
        $config['per_page'] = $per_page;
        $config['full_tag_open'] = '<div class="pagination pagination-centered" id="pagination1"><ul>';
        $config['full_tag_close'] = '</ul></div><!--pagination-->';
        $config['first_link'] = false;
        $config['last_link'] = false;
        $config['first_tag_open'] = '<li>';
        $config['first_tag_close'] = '</li>';
        $config['prev_link'] = 'Prev';
        $config['prev_tag_open'] = '<li class="prev">';
        $config['prev_tag_close'] = '</li>';
        $config['next_link'] = 'Next';
        $config['next_tag_open'] = '<li>';
        $config['next_tag_close'] = '</li>';
        $config['last_tag_open'] = '<li>';
        $config['last_tag_close'] = '</li>';
        $config['cur_tag_open'] = '<li class="active"><a href="#">';
        $config['cur_tag_close'] = '</a></li>';
        $config['num_tag_open'] = '<li>';
        $config['num_tag_close'] = '</li>';

        $this->pagination->initialize($config);
        $data['pagination'] = $this->pagination->create_links();
    }


    $data['level'] = $this->session->userdata('level');
    $data['pengguna'] = $this->model_user->get_username($this->session->userdata('username'));

    $data['data_request_done'] = $this->model_request->get_data_request_belum_terkoreksi($per_page, $start_row);
    $data['hitung_Request_Masuk_MD'] = $total_rows;

    $this->load->view('direksi/view_direksi', $data);
}

VIEW

<body>

<!-- start: Header -->
<?php $this->load->view('/direksi/include/header.php') ?>
<!-- start: Header -->  


<div class="container-fluid-full">
    <div class="row-fluid">
        <noscript>
        <div class="alert alert-block span12">
            <h4 class="alert-heading">Warning!</h4>
            <p>You need to have <a href="http://en.wikipedia.org/wiki/JavaScript" target="_blank">JavaScript</a> enabled to use this site.</p>
        </div>
        </noscript>

        <!-- start: Content -->
        <marquee>Jumlah Request Masuk ke MD: <?php echo $hitung_Request_Masuk_MD . ' request' ?></marquee>

        <div class="box-header">
            <h2><i class="halflings-icon align-justify"></i><span class="break"></span>Request masuk ke IT</h2>
            <div class="box-icon">
                <a href="#" class="btn-minimize"><i class="halflings-icon chevron-up"></i></a>
            </div>
        </div>

        <div class="box-content" id="things_table">
            <?php $this->load->view('direksi/view_direksi_table'); ?>
        </div>
    </div>
</div>
<!-- end: Content -->

<?php $this->load->view('direksi/view_direksi_table_modal', TRUE); ?>


<div class="clearfix"></div>

<?php $this->load->view('/include/js.html', TRUE); ?>
</body>

Any help, it so appreciated

Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
Fadly Dzil
  • 2,154
  • 3
  • 34
  • 85
  • set `$config['uri_segment']` to determine which segment of your URI contains the page number. [check this](https://ellislab.com/codeigniter/user-guide/libraries/pagination.html) – AVM Jun 09 '15 at 05:47

1 Answers1

0

change 01

$start_row = $this->uri->segment(4);//remove this

and post after

$config['base_url'] = base_url() . 'direksi/control_direksi/show/';
$config['total_rows'] = $total_rows;
$config['per_page'] = 2;
$config['uri_segment'] = 3;//Uri_Segment

Change 02

 $data['pagination'] = $this->pagination->create_links();

modify like this

 $page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;//Add this line
$data['links'] = $this->pagination->create_links();

Change 03

in view.

where you want show your pagination list just use

<?php
echo $links;
?>

Important load this library in controller as well

$this->load->library('pagination');
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85