迅睿CMS框架是一款PHP8高性能·簡單易用的CMS開源開發框架,基于MIT開源許可協議發布,免費且不限制商業使用,是免費開源的產品,以萬端互聯為設計理念,支持的微信公眾號、小程序、APP客戶端、移動端網站、PC網站等多終端式管理系統。
聯系官方銷售客服
1835022288
028-61286886
/book/diyizhangjie.html 章節路徑是這樣的
diyizhangjie 這段每個章節的標題拼音
請問rewrite.php里面偽靜態怎么寫 來對應/book/diyizhangjie.html 這個路徑
章節動態路徑 是這個 /index.php?s=book&c=son&m=show&id=10244
非常感謝
插件不支持這種自定義字段的url,他必須有id才行,例如/book/10244.html
--------非要這么來book/diyizhangjie.html,只能對son控制器進行二次開發,來找內容,否則內容是找不到的,就是404了
那獲取內容頁面拼音
/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規則上填
3、打開 config/rewrite.php 把原來的內容規則
/***********************獨立模塊測試規則:內容頁面的偽靜態解析*************************/
"([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控制器進行二次開發,來找內容,否則內容是找不到的,就是404了
那獲取內容頁面拼音
/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規則上填
3、打開 config/rewrite.php 把原來的內容規則
/***********************獨立模塊測試規則:內容頁面的偽靜態解析*************************/
"([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 兄弟首先非常感謝你 但是按你操作 還是不能打開頁面,拼音轉換時可以的