Ketika halaman kategori di beri paging, kok paging yang tampil sebanyak field di database

Jadi gini, pada saat saya memilih kategori, kemudian muncul paging nya, data yang muncul memang sesuai dengan kategori yang di pilih, tetapi halaman paging yang tampil sebanyak data di table posting

Model
<?php
    class KategoriM extends CI_Model{
        public function KategoriModel($id_kategori,$limit, $start){

 return $this->db->select('*')->from('posting')->join('kategori','kategori.id_kategori=posting.id_kat')->join('user','user.id_user=posting.id_user')->where(array('kategori','id_kategori'=> $id_kategori))->order_by('posting.id_kat','DESC')->limit($limit, $start)->get('')->result_array();

    }
    }


            // public function total_category($category_slug){
        //  $query = $this->db->query('SELECT count(category_id) FROM posts WHERE category_id = $category_slug');
        //  return $query->row();
        // }
    //
    ?>

View
<?php foreach($detailkategori as $data) : ?>
        <div class="col-md-4">
          <div class="card-box-b card-shadow news-box">
            <div class="img-box-b">
             <img src="<?php echo base_url('dashboard/user/posting/img/'.$data['gambar']) ?>"
            style="width: 290px;height: 385px" alt="" class="img-b img-fluid">
            </div>
            <div class="card-overlay">
              <div class="card-header-b">

                <div class="card-title-b">
                  <h2 class="title-2">
                    <a href="<?php echo base_url() ?>index.php/FileArtikel/baca/<?php echo $data['id_post']; ?>"><?php echo $data['judul_postingan']; ?></a>
                  </h2>
                </div>

                <div class="card-date">
                  <span class="date-b"><?php echo $data['tanggal_postingan'] ?><span>
                </div>

              </div>
            </div>
          </div>
        </div>
<?php endforeach; ?>

controler
<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Kat extends CI_Controller {

    public function __construct()
    {
        parent::__construct();
        $this->load->library('pagination');
        $this->load->model(array('KategoriM'));
    }

        public function kategori($nama_kategori){
         //konfigurasi pagination

        $config['base_url'] = site_url('Kat/kategori/'.$nama_kategori.'/
        '); //site url
        $config['total_rows'] = $this->db->count_all('posting'); //total row
        $config['per_page'] = 1;  //show record per halaman
        $config["uri_segment"] = 4;  // uri parameter
        $choice = $config["total_rows"] / $config["per_page"];
        $config["num_links"] = floor($choice);

        // Membuat Style pagination untuk BootStrap v4
        $config['first_link']       = 'First';
        $config['last_link']        = 'Last';
        $config['next_link']        = 'Next';
        $config['prev_link']        = 'Prev';
        $config['full_tag_open']    = '<div class="pagging text-center"><nav><ul class="pagination justify-content-center">';
        $config['full_tag_close']   = '</ul></nav></div>';
        $config['num_tag_open']     = '<li class="page-item"><span class="page-link">';
        $config['num_tag_close']    = '</span></li>';
        $config['cur_tag_open']     = '<li class="page-item active"><span class="page-link">';
        $config['cur_tag_close']    = '<span class="sr-only">(current)</span></span></li>';
        $config['next_tag_open']    = '<li class="page-item"><span class="page-link">';
        $config['next_tagl_close']  = '<span aria-hidden="true">»</span></span></li>';
        $config['prev_tag_open']    = '<li class="page-item"><span class="page-link">';
        $config['prev_tagl_close']  = '</span>Next</li>';
        $config['first_tag_open']   = '<li class="page-item"><span class="page-link">';
        $config['first_tagl_close'] = '</span></li>';
        $config['last_tag_open']    = '<li class="page-item"><span class="page-link">';
        $config['last_tagl_close']  = '</span></li>';

        $this->pagination->initialize($config);
        $data['page'] = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0;

        //panggil function get_mahasiswa_list yang ada pada mmodel mahasiswa_model.
$data['detailkategori'] = $this->KategoriM->KategoriModel($nama_kategori, $config["per_page"], $data['page']);

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

        $data['titlekategori'] = "List Kategori";
            $this->load->view('template/kategori',$data);
        }

}
?>

avatar azamir
@azamir

1 Kontribusi 0 Poin

Dipost 4 tahun yang lalu

Belum ada Jawaban. Jadi yang pertama Jawaban

Login untuk ikut Jawaban