在前兩篇隨筆中已經簡單介紹了phpcms, 那麼現在讓我們來看一下如何用phpcms將靜態網頁生成動態網頁?
1.在templates資料夾下新建範本資料夾ceshi(名字可以自己隨筆起)
2.在ceshi下面新建資料夾content(必須為content)
3.把靜態頁面拿到content資料夾裡面,順便改名字
4.把靜態網頁所用的資料夾(css,js,images)拿到statics資料夾下麵
5.後臺裡面設置範本改為ceshi(看範本風格配置)
6.替換路徑 {CSS_PATH}代表statics資料夾下的css資料夾目錄
7.將首頁拆分成三塊, header footer index
8.css、js放到相應的頁面
header用到的css,js放在header, index用到的css,js放在index裡
9.index裡面需要引入頭header和尾footer.
{template "content","header"}
{template "content","footer"}
10. 替換內容(基本的語法)
(1)替換目錄以及判斷是否為當前頁
{pc:content action="category" catid="0" num="4" siteid="$siteid" order="listorder ASC"} {loop $data $r} {if $catid==$r[catid]||$top_parentid==$r[catid]} {$r[catname]} {else} {$r[catname]} {/if} {/loop} {/pc} {if $top_parentid==0} 首頁 {else} 首頁 {/if}(2)替換內容:
{pc:content action="lists" catid="13" order="listorder ASC" num="4"} {loop $data $key $val} {/loop} {/pc}(3)嵌套 同時替換目錄和內容
{pc:content action="category" catid="0" num="4" siteid="$siteid" order="listorder ASC"} {loop $data $r} {$r[catname]} 更多>> {pc:content action="lists" catid="$r[catid]" order="listorder ASC" num="1"} {loop $data $key $val} {$val[description]} {/loop} {/pc} {/loop} {/pc}