聯(lián)系官方銷售客服
1835022288
028-61286886
/book/diyizhangjie.html 章節(jié)路徑是這樣的
diyizhangjie 這段每個(gè)章節(jié)的標(biāo)題拼音
請(qǐng)問rewrite.php里面?zhèn)戊o態(tài)怎么寫 來對(duì)應(yīng)/book/diyizhangjie.html 這個(gè)路徑
章節(jié)動(dòng)態(tài)路徑 是這個(gè) /index.php?s=book&c=son&m=show&id=10244
非常感謝
插件不支持這種自定義字段的url,他必須有id才行,例如/book/10244.html
--------非要這么來book/diyizhangjie.html,只能對(duì)son控制器進(jìn)行二次開發(fā),來找內(nèi)容,否則內(nèi)容是找不到的,就是404了
那獲取內(nèi)容頁面拼音
/xiaoshuoneirongye/10244.html
這個(gè)如何寫
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 把原來的內(nèi)容規(guī)則
/***********************獨(dú)立模塊測(cè)試規(guī)則:內(nèi)容頁面的偽靜態(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
回復(fù)@LandQ 兄弟首先非常感謝你 但是按你操作 還是不能打開頁面,拼音轉(zhuǎn)換時(shí)可以的