網站程式設計-PHP
一、在程式選擇「佈景」
- 實體路徑:WEB_PATH
 - 網址:WEB_URL
 - 佈景目錄:$WEB['theme_name']
 - 程式檔名:$WEB['file_name']
 - 以上兩個常數、兩個變數是在前的 head.php設定,由於 $WEB['theme_name']是變數,意味我們在程式中可以改變,而達到換佈景的功能。
 
二、將程式變數送至「佈景」
- /*---- 將變數送至樣版----*/ $smarty->assign("WEB", $WEB); /*---- 程式結尾-----*/ $smarty->display('theme.html');
 - 透過 $smarty->assign("WEB", $WEB); 將變數或陣列,送至佈景
 - smarty保留的變數請參考:https://www.ugm.com.tw/modules/tad_book3/page.php?tbdsn=362
 
三、新增佈景
- 下載前台佈景:https://startbootstrap.com/template-overviews/creative/
 - 下載後台佈景:https://startbootstrap.com/template-overviews/sb-admin-2/
 - 位置:smarty_01/templates
 - 將下載檔案的目錄名稱,改成前台「default」,後台「admin」
 - 將佈景裡的「index.html」改為 「theme.html」
 
四、編輯佈景
| 說明 | 後台變數、常數 | 前台樣板 | 
| 實體路徑 | WEB_PATH | <{$samrty.const.WEB_PATH}> | 
| 網址 | WEB_URL | <{$samrty.const.WEB_URL}> | 
| 佈景名稱 | $WEB['theme_name'] | <{$WEB.theme_name}> | 
| 程式檔名(含副檔名) | $WEB['file_name'] | <{$WEB.file_name}> | 
| 佈景目錄(含 / ) | <{$themeUrl}> | |
| 網站標題 | $WEB['title'] | <{$WEB.title}> | 
- 更改標題
 -  
	
    <!-- Bootstrap Core CSS -->
    <link href="vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet">
	
 - 修改samrty.php 將「<{$themeUrl}>」變數修改成不含「/」
	
#定義模板URL
$smarty->assign("themeUrl", WEB_URL.'/templates/'.$WEB['theme_name']);//修改不含「/」20161020
	
 - ctrl + H 取代功能
「"<{$themeUrl}>/vendor/」 取代「"vendor/」
「"<{$themeUrl}>/css/」取代 「"css/」
「"<{$themeUrl}>/img/」取代 「"img/」
「"<{$themeUrl}>/js/」取代 「"js/」 
五、建立後台
- 建立「admin」資料夾
 - 把「/head.php」、「/index.php」複製到 「/admin」
 - /admin/head.php,由於多了一個資料夾admin,所以「WEB_PATH」的路徑多了 「/admin」
	
define('WEB_PATH', str_replace("\\","/",dirname(__FILE__)));//前台
	 修改
	
define('WEB_PATH', str_replace("/admin","",str_replace("\\","/",dirname(__FILE__))));//後台
	
 - 佈景目錄 => $WEB['theme_name'] = "admin";
 - /admin/head.php
	
/*---- 必須引入----*/
#引入樣板引擎
require_once '../smarty.php';
#引入資料庫設定
require_once '../sqlConfig.php';
#引入共用函數
require_once '../function.php';
	
 - 把 /templates/admin/index.html 刪除,複製  /templates/admin/pages/blank.html =>  /templates/admin/theme.html
「"<{$themeUrl}>/vendor/」 取代「"../vendor/」
「"<{$themeUrl}>/dist/」取代 「"../dist/」