Codeigniter 当我在分页时单击下一个编号时,链接仍在编号1处活动

Codeigniter 当我在分页时单击下一个编号时,链接仍在编号1处活动,codeigniter,pagination,Codeigniter,Pagination,我的控制器功能 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class News extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('news_media');

我的控制器功能

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class News extends CI_Controller {

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

    public function index()
    {
        $config['base_url']     = base_url()."secret/news/index";
        $config['total_rows']   = $this->news_media->getCount();
        $config['per_page']     = 3;
        $this->pagination->initialize($config);
        $page = ($this->uri->segment(4))?$this->uri->segment(4):0;

        $data = array();
        $data['allnews']    = $this->news_media->get($config['per_page'],$page);
        $data['links']      = $this->pagination->create_links();

        $html               = array();
        $html['title']      = "Setting";
        $html['head']       = $this->load->view('secret/template/header',null, true);
        $html['top']        = $this->load->view('secret/template/top',null, true);
        $html['menu']       = $this->load->view('secret/template/menu',null, true);
        $html['content']    = $this->load->view('secret/news/news',$data, true);
        $html['js']         = $this->load->view('secret/template/js',null, true);
        $this->load->view('secret/template/template',$html);
    }
}

在分页配置设置中添加
uri_段

$config['base_url']     = base_url()."secret/news/index";
$config['total_rows']   = $this->news_media->getCount();
$config['per_page']     = 3;
$config["uri_segment"]  = 4;

$this->pagination->initialize($config);
希望这将帮助您解决这个问题。看一看,解释一下

$config['uri_段]]=3

分页函数自动确定URI的哪个段包含页码。如果你需要一些不同的东西,你可以指定它


您希望在第2页和第3页上显示的确切url是什么