我可以通过在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]
但是当我在Pagination中生成链接时,后缀不会添加到生成的其他页面的链接中。
我们可以通过配置做任何设置,还是需要修改库文件。
答案 0 :(得分: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:我是阿根廷人,我的英语技能有点差。
答案 1 :(得分:0)
在你的application / 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'] = '';