Ordonate 分页 codeigniter

ordonate pagination codeigniter

我的 url 有问题。我的分页效果很好,但看起来不太好。 例如,我想查看第 2 页,link 变为:localhost/page/9,第 3 页变为 localhost/page/18 我试试这个功能:

if($this->uri->segment($config['uri_segment']))
    {
        $offset = $this->uri->segment($config['uri_segment']);
        $segment_to_replace = $this->uri->segment(2);
        $new_id = $this->uri->segment(2) / 9 +1;
        $new_url = str_replace ($segment_to_replace, $new_id, current_url());
        redirect($new_url);
    }

但是代码不起作用。 首先,var_dup($new_url) return localhost/page/2 和 redirect($new_url) return localhost/page/1.222222222。 另一个问题是连续重定向。我怎样才能让 URL 显示当前页面而不是我的代码的偏移量。

完整代码:

    $this->load->library('pagination');

    $config['base_url'] = 'http://localhost/page/';

    $config['total_rows'] = $this->product_model->count('active');
    $config['per_page'] = 9;
    $config['num_links'] = 3;
    $config['uri_segment'] = 2;
    $config['cur_tag_open'] = ' <b>';
    $config['prev_link'] = 'Previous';
    $config['next_link'] = 'Next';
    $this->pagination->initialize($config);

    if($this->uri->segment($config['uri_segment']))
    {
        $offset = $this->uri->segment($config['uri_segment']);
        $segment_to_replace = $this->uri->segment(2);
        $new_id = $this->uri->segment(2) / 9 +1;
        $new_url = str_replace ($segment_to_replace, $new_id, current_url());

        var_dump($new_url); die;
        return redirect($new_url);
    }
$config['use_page_numbers'] = TRUE;

By default, the URI segment will use the starting index for the items you are paginating. If you prefer to show the the actual page number, set this to TRUE.

Docs.