0

我可以通过在 CI config.php 文件中添加后缀“.html”来将页面 example.com/index.php/products/view/shoes 制作为 example.com/index.php/products/view/shoes.html。[参考:http://ellislab.com/codeigniter/user-guide/general/urls.html]

但是当我在分页中生成链接时,后缀不会添加到生成的指向其他页面的链接中。

有没有我们可以通过配置做的设置或者我们需要修改库文件。

4

2 回答 2

4

您可以通过这种方式为分页链接定义后缀:

$config['suffix'] = YOUR_SUFFIX

看我的例子:

网址:http ://www.test_store.com/products/index/order/low_price

// Parsing the URI
$uri = $this->uri->uri_to_assoc(3);

$page     = !empty($uri['page'])   ? $uri['page']   : 1;
$order    = !empty($uri['order'])  ? $uri['order']  : false;

// Search paginated
$this->Product->limit  = $per_page;
$this->Product->offset = ($page - 1) * $per_page;
$this->Product->order  = $order;

$products = $this->Product->get_all();

// Pagination config
$config['base_url']         = site_url('products/index/page');
$config['total_rows']       = $this->Product->count_all();
$config['uri_segment']      = 4;
$config['num_links']        = 5;
$config['use_page_numbers'] = TRUE;
$config['per_page']         = $per_page; 

// Add a suffix to pagination links
$config['suffix'] = !empty($uri['order']) ? '/order/'. $uri['order'] : ''; 

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

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

PD:我是阿根廷人,我的英语水平有点差

于 2013-10-16T17:52:57.183 回答
0

在您的应用程序/config/config.php 中:

/*
|--------------------------------------------------------------------------
| URL suffix
|--------------------------------------------------------------------------
|
| This option allows you to add a suffix to all URLs generated by CodeIgniter.
| For more information please see the user guide:
|
| http://codeigniter.com/user_guide/general/urls.html
*/

$config['url_suffix'] = '';
于 2013-10-01T09:40:35.653 回答