CodeIgniter:分页显示“per_page”两次?

时间:2011-12-03 14:35:13

标签: codeigniter codeigniter-2

我正在使用CI的分页库。这是我的配置:

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

$config                   = array();
$config['base_url']       = 'http://localhost/index.php/search/';
$config['total_rows']     = 200;
$config['per_page']       = 10;
$config['num_links']      = 4;

$config['full_tag_open']  = '<ol>';
$config['full_tag_close'] = '</ol>';

$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']      = 'Next';
$config['next_tag_open']  = '<li>';
$config['next_tag_close'] = '</li>';

$config['prev_link']      = 'Previous';
$config['prev_tag_open']  = '<li>';
$config['prev_tag_close'] = '</li>';

$config['cur_tag_open']  = '<li class="active">';
$config['cur_tag_close'] = '</li>';

$config['num_tag_open']  = '<li>';
$config['num_tag_close'] = '</li>';

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

结果链接有per_page两次,例如你看到这里:

http://localhost/index.php/search/&per_page=&per_page=10有什么想法?

1 个答案:

答案 0 :(得分:0)

你在代码的最后两行

中回应了两次

替换:

echo htmlentities($this->pagination->create_links());
echo ($this->pagination->create_links());

要:

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

您应该将变量传递给视图,而不是从控制器回显它。