如何在uri->段(1)中路由分页下一页,例如(example.com/1)

时间:2013-09-04 11:58:28

标签: php codeigniter

当我点击分页的第二页时,我在前端索引页面example.com中有分页,我想加载页面,例如example.com/1

<?php 

function index()
{
    $e = $this->employer_model->count_jobs_with_employer();
    //print_r($e) ;
    $config['base_url'] = $this->config->site_url(); //set the base url for pagination
    $config['total_rows'] = $e; //total rows
    $config['per_page'] = '10'; //the number of per page for pagination
    $config['uri_segment'] = 1; //see from base_url. 3 for this case        
    $config['first_link'] = 'First';
    $config['last_link'] = 'Last';

    $config['full_tag_open'] = '<div class="pagination">';
    $config['full_tag_close'] = '</div>';
    $this->pagination->initialize($config); //initialize pagination

    $page  = ($this->uri->segment(1)) ? $this->uri->segment(1) : 0;

    $joblist['listemp'] = $this->employer_model->employerbyjob($config['per_page'], $page); 
    foreach($joblist['listemp'] as $emp)
    {
        $joblist['jobs'][$emp->u_id] =   $this->employer_model->get_ByTbl_Col('employer_post_job', 'e_id', $emp->u_id,'dead_line', date('Y-m-d'));  
    }

    $c['job_list'] = $this->load->view('front/blocks/employer/job_list', $joblist, TRUE);
}
?>

1 个答案:

答案 0 :(得分:1)

这样的事情应该有效:

<强>应用/配置/ routes.php文件:

//default routes:
$route['default_controller'] = "yourcontroller";
$route['404_override'] = '';

// your custom route:
$route['(:num)'] = "yourcontroller/index/$1";

<强>应用/控制器/ Yourcontroller.php

function index($page = null)
{

}