1. 程式人生 > >“字符串替換” 和 “模板設置” (application/config.php)

“字符串替換” 和 “模板設置” (application/config.php)

str 設置 pla ati pub 視圖 模板文件 字符串替換 定義

//視圖輸出字符串內容替換
‘view_replace_str‘ => [
‘__PUBLIC__‘ => ‘/public/‘,
‘__ROOT__‘ => ‘/‘,
],

模板設置:
template下添加:
‘layout_on‘ => true,
‘layout_name‘ => ‘layout‘,
‘layout_item‘ => ‘[__REPLACE__]‘

同時layout.html改為[__REPLACE__]
{include file="templet/header" /}
[__REPLACE__]
{include file="templet/footer" /}

或者layout.html
{include file="templet/header" /}
{__CONTENT__}
{include file="templet/footer" /}
另外在使用index.html中加
{layout name="layout" /}
文件中開頭定義 layout 標簽 ,表示當前模板使用了布局,布局模板文件為 layout.html ,
布局模板中的 {__CONTENT__} 會自動替換為解析後的index.html內容。

“字符串替換” 和 “模板設置” (application/config.php)