mercredi 27 mars 2019

CodeIgniter pagination active Links not Working

I have a code where clicking on pagination links functions fine , but if i click on a link that particular link is not showing as active link . my code is as follows:

controller:

    $config['base_url'] = base_url().'posts/index';
    $config['total_rows'] = $this->db->count_all('posts');
    $config['per_page'] = 10;
    $config["use_page_numbers"] = TRUE;
    $config['uri_segment'] = 2;
    $config['num_links'] = 4;
    $offset = $this->uri->segment(4, 0);
   $config['full_tag_open'] = '<ul class="pagination">';
   $config['full_tag_close'] = '</ul>';
   $config['num_tag_open'] = '<li class="page-item">';
   $config['num_tag_close'] = '</li>';
   $config['cur_tag_open'] = '<li class="page-item active"><a class="page-link" href="#">';
   $config['cur_tag_close'] = '</a></li>';
   $config['next_tag_open'] = '<li class="page-item">';
   $config['next_tagl_close'] = '</a></li>';
   $config['prev_tag_open'] = '<li class="page-item">';
   $config['prev_tagl_close'] = '</li>';
   $config['first_tag_open'] = '<li class="page-item disabled">';
   $config['first_tagl_close'] = '</li>';
   $config['last_tag_open'] = '<li class="page-item">';
   $config['last_tagl_close'] = '</a></li>';
   $config['attributes'] = array('class' => 'page-link');
  //\\ $config['page_query_string'] = TRUE;   

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

model:

    public function get_posts($limit = false,$start = false){
    if ( $limit ){
        $this->db->limit($limit,$start);
    }
    //$query = $this->db->get('posts');
    $this->db->order_by('created_at','desc');
    $this->db->select('posts.*, tags.name');
    $this->db->from('posts');
    $this->db->join('tags', 'tag_id = tags.id');
    $query = $this->db->get();

    return $query->result_array();
}




Aucun commentaire:

Enregistrer un commentaire