CodeIgniter-如何将字符串添加到分页链接?

CodeIgniter-如何将字符串添加到分页链接?,codeigniter,pagination,Codeigniter,Pagination,我想在生成的分页链接的末尾添加一些字符串/值。 例如,我得到这个 http://localhost/products/lists/5 我想要 http://localhost/products/lists/5/value/anothervalue 所以,我需要以某种方式发送这些值…:) 谢谢大家。应用程序/config/routes.php $route['products/lists/(:num)/value/(:any)'] = "products/lists/$1/$2"; 控制器

我想在生成的分页链接的末尾添加一些字符串/值。 例如,我得到这个

http://localhost/products/lists/5
我想要

http://localhost/products/lists/5/value/anothervalue
所以,我需要以某种方式发送这些值…:)


谢谢大家。

应用程序/config/routes.php

 $route['products/lists/(:num)/value/(:any)'] = "products/lists/$1/$2";
控制器代码application/controllers/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));
    }
}
如果您的url类似于
http://localhost/products/lists/5/value/anothervalue

在函数
列表中,
将是$page=5和$value='anothervalue',它们将在模板
产品列表中可用($page,$value)

应用程序/config/routes.php

 $route['products/lists/(:num)/value/(:any)'] = "products/lists/$1/$2";
控制器代码application/controllers/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));
    }
}
如果您的url类似于
http://localhost/products/lists/5/value/anothervalue

在函数
列表中,
将是$page=5和$value='anothervalue',它们将在模板
产品列表中可用($page,$value)

分页类有一个名为后缀的未记录配置选项,您可以使用它。以下是我如何在我的一个应用程序中使用它:

// 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
));

分页类有一个名为后缀的未记录配置选项,您可以使用它。以下是我如何在我的一个应用程序中使用它:

// 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
));

是萨默兹!特克斯!已经搜索了2天,但从未看到过该解决方案!:)是萨默兹!特克斯!已经搜索了2天,但从未看到过该解决方案!:)