下面是自定義單頁面的,文章中心的模板怎樣可以自定義呢?謝謝
打開根目錄下“page.php”找到
$smarty->display('page.dwt');
改為
// 自定義單頁面調用模板
if (file_exists(ROOT_PATH . "theme/$_CFG[site_theme]/" . $page['unique_id'] . '.dwt')) {
$smarty->display($page['unique_id'] . '.dwt');
} else {
$smarty->display('page.dwt');
}
然后在對應的模板目錄中新建格式為“單頁面別名.dwt”的模板文件即可
由DouPHP官方技術于2019-08-21 11:43回答
參考這部分代碼,可以使用文章ID作為標記,比如
if (file_exists(ROOT_PATH . "theme/$_CFG[site_theme]/" . 'article_' . $id . '.dwt')) {
$smarty->display('article_' . $id . '.dwt');
} else {
$smarty->display('page.dwt');
}
if (file_exists(ROOT_PATH . "theme/$_CFG[site_theme]/" . 'article_' . $id . '.dwt')) {
$smarty->display('article_' . $id . '.dwt');
} else {
$smarty->display('page.dwt');
}
有用(2) 沒用(2)