CodeIgniter分页配置错误?

时间:2012-09-19 23:44:16

标签: codeigniter codeigniter-2

请在名为“test”的控制器中查看以下代码:

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

// These 3 are the minimum config that needs to be set
$config['base_url']   = base_url() . 'test/?' . http_build_query($_GET, '', '&');
$config['total_rows'] = 173;
$config['per_page']   = 20;

// This returns something like this: ?name=foo/20
// I would expect something like this: ?name=foo&per_page=20
// $config['enable_query_strings'] = TRUE;

// This retuns something like this: ?name=foo&per_page=20 (which is what I want),
// but the documentation says it should be: ?c=test&m=index&per_page=20
$config['page_query_string'] = TRUE;

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

然后转到:test/?name=foo

生成的分页链接看起来正确。当您点击链接号码“2”时,您将被重定向到?name=foo&per_page=20,这是正确的。然而,创建的新分页看起来是错误的。它看起来像这样:?name=foo&per_page=20&per_page=40(其中per_page在查询字符串中出现两次)。

发生了什么事?

1 个答案:

答案 0 :(得分:0)

添加uri细分

$config['uri_segment'] = x ;