1

I have one problem in Codeigniter pagination with segments. I need to pass segments with page number.

Example: http://www.mysite.com/app/controller/method/param1/param2/page_number

<?php

$this->load->library('pagination');
$config['base_url'] = 'http://localhost/welcome/par1/para2/';
$config['total_rows'] = 200;
$config['per_page'] = 20;

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

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

?>
4

1 回答 1

0

尝试使用 URL 帮助函数 current_url() 作为您的基本 URL。

从 CI 文档(http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html):

current_url() - 返回当前正在查看的页面的完整 URL(包括段)。

因此,在您的情况下,控制器将如下所示:

$this->load->library('pagination');
$config['base_url'] = current_url();
$config['total_rows'] = 200;
$config['per_page'] = 20;

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

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

此方法应允许您拥有所需数量的参数。

于 2013-03-19T21:59:30.653 回答