我想添加一些字符串/值到生成的分页链接的结尾。 例如,我得到这个CodeIgniter - 如何添加字符串到分页链接?
http://localhost/products/lists/5
我想有
http://localhost/products/lists/5/value/anothervalue
所以,我需要以某种方式发送这些值... :)
谢谢ü所有。
我想添加一些字符串/值到生成的分页链接的结尾。 例如,我得到这个CodeIgniter - 如何添加字符串到分页链接?
http://localhost/products/lists/5
我想有
http://localhost/products/lists/5/value/anothervalue
所以,我需要以某种方式发送这些值... :)
谢谢ü所有。
分页类有一个可以使用的称为后缀的未公开的配置选项。以下是我在其中一个应用中使用它的方法:
// get the current url segments and remove the ones before the suffix
// http://localhost/products/lists/5/value/anothervalue
$args = $this->uri->segment_array();
unset($args[1], $args[2], $args[3]);
$args = implode('/', $args);
// $args is now 'value/anothervalue'
$base_url = 'http://localhost/products/lists';
$this->pagination->initialize(array(
'base_url' => $base_url,
'suffix' => '/'.$args,
'first_url' => $base_url.'/1/'.$args,
'uri_segment' => 3
));
应用程序/配置/ routes.php文件
$route['products/lists/(:num)/value/(:any)'] = "products/lists/$1/$2";
控制器代码应用程序/控制器/ products.php
class Products extends CI_Controller {
public function index() {
$this->load->view('welcome_message');
}
public function lists($page = 1, $value = null) {
$this->load->view('product_lists', array('page' => $page, 'value' => $value));
}
}
这样,如果您的网址是像http://localhost/products/lists/5/value/anothervalue
在功能lists
会$ page = 5和$ value ='anothervalue',它们将在模板中可用product_lists
($ page,$ value)
就是这样它Samutz! TNKS! 一直在寻找2天,并从未见过这种解决方案! :) – PJunior 2013-04-28 22:36:45