迅睿開源框架是一款PHP8高性能·簡單易用的PHP開源開發(fā)框架, 基于MIT開源許可協議發(fā)布,不限制商業(yè)使用,以多端互聯為設計理念, 支持的微信公眾號、小程序、APP客戶端、移動端網站、PC網站等多終端式管理系統。
業(yè)務經理
微信掃描以上二維碼
028-61286886
技術咨詢
/book/diyizhangjie.html 章節(jié)路徑是這樣的
diyizhangjie 這段每個章節(jié)的標題拼音
請問rewrite.php里面?zhèn)戊o態(tài)怎么寫 來對應/book/diyizhangjie.html 這個路徑
章節(jié)動態(tài)路徑 是這個 /index.php?s=book&c=son&m=show&id=10244
非常感謝
插件不支持這種自定義字段的url,他必須有id才行,例如/book/10244.html
--------非要這么來book/diyizhangjie.html,只能對son控制器進行二次開發(fā),來找內容,否則內容是找不到的,就是404了
開源是一種精神,但不是義務,幫忙是情分,不幫也不要抱怨,建議大家多研究代碼、多閱讀代碼、多翻閱社區(qū)歷史問題!
那獲取內容頁面拼音
/xiaoshuoneirongye/10244.html
這個如何寫
1、打開 config/custom.php 添加自定義方法
function book_url($data)
{
$py = \Phpcmf\Service::L('pinyin')->result($data['title']);
\Phpcmf\Service::L("cache")->set_file("dr_book_".$py, $data['id'], "dr_book");
return "/book/" . $py . ".html";
}
2、URL規(guī)則上填
3、打開 config/rewrite.php 把原來的內容規(guī)則
/***********************獨立模塊測試規(guī)則:內容頁面的偽靜態(tài)解析*************************/
"([a-z]+)\/show\/([0-9]+).html(.*)" => 'index.php?s=$1&c=show&id=$2',
改成
"([a-z]+)\/([a-z0-9]+).html(.*)" => 'index.php?s=$1&c=show&id=$2',
4、打開 dayrui/App/Book/Controllers/Show.php 找到第6行的index方法
public function index() {
$this->_module_init();
$this->_Show(
(int)\Phpcmf\Service::L('Input')->get('id'),
[
'field' => dr_safe_replace(\Phpcmf\Service::L('Input')->get('field')),
'value' => dr_safe_replace(\Phpcmf\Service::L('Input')->get('value')),
],
max(1, (int)\Phpcmf\Service::L('Input')->get('page'))
);
$id = \Phpcmf\Service::L('Input')->get('id');
if ($cid = \Phpcmf\Service::L("cache")->get_file("dr_book_".$id , "dr_book")) {
$id = $cid;
(int)$id,
5、更新URL
回復@LandQ 兄弟首先非常感謝你 但是按你操作 還是不能打開頁面,拼音轉換時可以的
插件不支持這種自定義字段的url,他必須有id才行,例如/book/10244.html
--------非要這么來book/diyizhangjie.html,只能對son控制器進行二次開發(fā),來找內容,否則內容是找不到的,就是404了
開源是一種精神,但不是義務,幫忙是情分,不幫也不要抱怨,建議大家多研究代碼、多閱讀代碼、多翻閱社區(qū)歷史問題!
那獲取內容頁面拼音
/xiaoshuoneirongye/10244.html
這個如何寫
1、打開 config/custom.php 添加自定義方法
function book_url($data)
{
$py = \Phpcmf\Service::L('pinyin')->result($data['title']);
\Phpcmf\Service::L("cache")->set_file("dr_book_".$py, $data['id'], "dr_book");
return "/book/" . $py . ".html";
}
2、URL規(guī)則上填
3、打開 config/rewrite.php 把原來的內容規(guī)則
/***********************獨立模塊測試規(guī)則:內容頁面的偽靜態(tài)解析*************************/
"([a-z]+)\/show\/([0-9]+).html(.*)" => 'index.php?s=$1&c=show&id=$2',
改成
"([a-z]+)\/([a-z0-9]+).html(.*)" => 'index.php?s=$1&c=show&id=$2',
4、打開 dayrui/App/Book/Controllers/Show.php 找到第6行的index方法
public function index() {
$this->_module_init();
$this->_Show(
(int)\Phpcmf\Service::L('Input')->get('id'),
[
'field' => dr_safe_replace(\Phpcmf\Service::L('Input')->get('field')),
'value' => dr_safe_replace(\Phpcmf\Service::L('Input')->get('value')),
],
max(1, (int)\Phpcmf\Service::L('Input')->get('page'))
);
}
改成
public function index() {
$this->_module_init();
$id = \Phpcmf\Service::L('Input')->get('id');
if ($cid = \Phpcmf\Service::L("cache")->get_file("dr_book_".$id , "dr_book")) {
$id = $cid;
}
$this->_Show(
(int)$id,
[
'field' => dr_safe_replace(\Phpcmf\Service::L('Input')->get('field')),
'value' => dr_safe_replace(\Phpcmf\Service::L('Input')->get('value')),
],
max(1, (int)\Phpcmf\Service::L('Input')->get('page'))
);
}
5、更新URL
回復@LandQ 兄弟首先非常感謝你 但是按你操作 還是不能打開頁面,拼音轉換時可以的