分页链接在codeginiter中不起作用

时间:2016-06-28 06:59:43

标签: php codeigniter

我的控制器: -

function all_leads($offset = 0) {
    $where = '';
    $search['search_status'] = FALSE;
    $username = $this->session->userdata('username');
    $user_id = $this->extra_functions->get_user_id($username);
    $this->load->library('pagination');
    $user_type = $this->extra_functions->get_user_type($user_id);
    if ($this->input->get('search')) {
       $serach_string = $this->input->server('QUERY_STRING');
       $config['enable_query_strings'] = TRUE;
       $config['suffix'] = '?' . $serach_string;
       $search_data = $this->input->get();
       $where = $this->lead_model->lead_search_coundtiotn($search_data);
       if ($where != NULL) {
          $where = $where;
       } else {
          $where = '';
       }
       $main_data['search'] = TRUE;
       $main_data['search_data'] = $search_data;
    }
    $num_rows = $this->lead_model->count_leads($user_id, $user_type, $where);
    $config['base_url'] = base_url('lead/all_leads');
    $config['total_rows'] = $num_rows;
    $config['per_page'] = 10;
    $config['use_page_numbers'] = TRUE;
    $config['full_tag_open'] = '<ul class="pagination">';
    $config['full_tag_close'] = '</ul>';
    $config['prev_link'] = '&laquo;';
    $config['prev_tag_open'] = '<li>';
    $config['prev_tag_close'] = '</li>';
    $config['next_tag_open'] = '<li>';
    $config['next_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>';
    $config['num_links'] = 5;
    $config['first_link'] = 'First';
    $config['first_tag_open'] = '<li>';
    $config['first_tag_close'] = '</li>';
    $config['last_link'] = 'Last';
    $config['last_tag_open'] = '<li>';
    $config['last_tag_close'] = '</li>';
    $config['next_link'] = '&raquo;';
    $this->pagination->initialize($config);
    $main_data['all_leads'] = $this->lead_model->view_leads_sec($config['per_page'], $offset, $search, $user_id, $user_type, $where);    
    $main_data['totalRecords']=$num_rows;
    $this->load->view('crm/leads/all_leads', $main_data);          
}

2 个答案:

答案 0 :(得分:0)

WriteLiteral(@"\\\\\\\\\\\\\" + @"\\\\\\\\\" + ...

答案 1 :(得分:-1)

在配置文件夹

中使用自动加载

EXP:

$autoload['libraries'] = array('database','session','encrypt','pagination'); 

这是我的分页风格,可能对你有用。

我的控制器:

public function album($id){
        $id = $this->uri->segment(3);
        $encpt = $this->encrypt->encode('howmuch?');
        # fetch records from database 
        //$this->data['posts'] = $this->Punjabi_Model->fetch_top_album($id);
        $config = array();
        $config["base_url"] = base_url() . "punjabi_music/album/".$id.'/';
        $config["total_rows"] = $this->Punjabi_Model->total_record($id);
        $config["per_page"] = 20;
        $config["uri_segment"] = 4;

        $this->pagination->initialize($config);

        $page = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0;
        $this->data['posts'] = $this->Punjabi_Model->fetch_top_album($id,$config["per_page"], $page);
        $this->data['links'] = $this->pagination->create_links();


        $this->middle ='other/punjabi_music/album';
        $this->layout();

    }