讓codeigniter分頁類支援URL自定義字尾

2021-05-24 15:11:19 字數 591 閱讀 4442

由於code的遺留問題,分頁類是不支援url自定義字尾的,假設你設定url自定義字尾是.html的話,分頁產生的鏈結是這樣的:

http://www.xx.com/class/method/par1/par2.htm/page  [其中page是頁數]

而我們的理想要求是:http://www.xx.com/class/method/par1/par2/page.html

我們可以簡單修改下就可以做到了,在:pagination類的create_links方法中在最後即

return $output;

前加上三行**:

$url_suffix=$ci->config->item('url_suffix');   

$output=str_replace($url_suffix,'',$output);   

$output=preg_replace("///([0-9]+)/"/","///1".$url_suffix."/"",$output); 

這樣就可以獲得在分頁情況下的:http://www.xx.com/class/method/par1/par2/page.html 理想型別

CodeIgniter中Router類的兩個方法

file location system core router.php 第乙個 fetch the current method access public return string function fetch method return this method 第二個 fetch the c...

共享 codeigniter配置類庫

本類庫主要用來方便操作站點設定,比如 網域名稱,是否允許註冊等的設定。這類設定的資料表的設計一般為 id key value,比如key為site domain,value儲存對應的值,如 url 資料庫 create table option oid int 11 not null auto in...

使用配置類定義 Codeigniter 全域性變數

config 的陣列。如果需要新增全域性配置項,可以在這個檔案中實現,考慮到自定義配置和框架配置的分離,建議新建乙個檔案 vars.php,然後做如下定義 工作目錄配置 config src cache fcpath src cache config src modules fcpath src m...