PHPCMS 2008 SP3 模板語法規(guī)則整理
發(fā)布時(shí)間:2011-09-13 16:51:02 作者:佚名
我要評(píng)論

PHPCMS 2008 SP3 模板語法規(guī)則整理,需要的朋友可以收藏下。
一、模板語法規(guī)則
1、變量表示
{$name} 被解析成 <?=$name?>,表示顯示變量$name的值,其中的“name”由英文字母、數(shù)字和下劃線組成首字母必須是英文字母或者下劃線。
2、常量表示
{name}被解析成<?=name?>,表示顯示常量name的值,其中的“name”由英文字母、數(shù)字和下劃線組成首字母必須是英文字母或者下劃線。
3、條件判斷
{if *} * {else} * {else} * {/if} 或者 {if *} * {/if},其中{if *}中的*就是此判斷語句的條件表達(dá)式,符合php的表達(dá)式。
{if $userid} {$username}{else} {$noname}{/if}
4、循環(huán)
{loop $a $b} * {/loop} 或者 {loop $a $b $c} * {/loop} ,{loop $a $b} * {/loop}
被解析成 <? if(is_array($a)) foreach($a AS $b) { ?> * <? } ?>
而 {loop $a $b $c} * {/loop} 則被解析成 <? if(is_array($a)) foreach($a AS $b=>$c) { ?> * <? } ?>
5.模板包含
{template 'module name','file name'}例如: {template 'phpcms','header'}表示包含模板目錄,phpcms目錄下header.html文件
建議 if 和 loop 語法應(yīng)該寫在html注釋符之間,這樣可以避免在編輯工具中難看,例如:
這樣寫 if
<!--{if $a>$b}--> <!--{else}--> <!--{/if}-->
這樣寫 loop
<!--{loop $arr $key $val}--> <!--{/loop}-->
如果您不習(xí)慣這套語法,也可以直接在模板中書寫php代碼,例如<?php echo 'Hello World!';?>
二、模板制作常用變量
常用的系統(tǒng)變量
打開文件 ./include/common.inc.php
IP //取得ip
TIME //取得時(shí)間戳,格式(1229393941 )可以通過date 函數(shù)格式化一個(gè)本地時(shí)間/日期,請(qǐng)參考php手冊(cè)
URL //取得當(dāng)前瀏覽的url地址
SITE_URL //網(wǎng)站的url地址
//以上是系統(tǒng)常量,直接調(diào)用,如()
$MODULE //系統(tǒng)模塊信息
[MODULE][phpcms] => Array
(
[module] => phpcms
[name] => Phpcms
[path] =>
[url] =>
[iscore] => 1
[version] => 1.0.0.0
)
$MODEL //模型信息
[MODEL] => Array
(
[1] => Array
(
[modelid] => 1
[name] => 新聞
[description] =>
[tablename] => news
[itemname] => 新聞
[itemunit] => 篇
[workflowid] => 1
[template_category] => category
[template_list] => list
[template_show] => show
[template_print] => print
[ishtml] => 1
[category_urlruleid] => 1
[show_urlruleid] => 7
[enablesearch] => 1
[ischeck] => 1
[isrelated] => 1
[disabled] => 0
[modeltype] => 0
)
)
$CATEGORY //欄目信息
[CATEGORY] => Array
(
[1] => Array
(
[catid] => 1
[module] => phpcms
[type] => 1
[modelid] => 0
[catname] => 網(wǎng)站介紹
[style] =>
[image] =>
[catdir] => about
[url] => /cms/phpcms_utf/about/index.html
[parentid] => 0
[arrparentid] => 0
[parentdir] =>
[child] => 1
[arrchildid] => 1,2,3,4,5
[items] => 0
[ismenu] => 0
)
)
$TYPE //類型信息
[TYPE] => Array
(
[1] => Array
(
[typeid] => 1
[module] => link
[name] => 默認(rèn)分類
[style] =>
[typedir] =>
[url] =>
)
)
$AREA //地區(qū)信息
[AREA] => Array
(
[1] => Array
(
[areaid] => 1
[name] => 北京
[style] =>
[parentid] => 0
[arrparentid] => 0
[child] => 0
[arrchildid] => 1
)
)
$URLRULE //url規(guī)則信息
[URLRULE] => Array
(
[1] => {$categorydir}/index.{$fileext}|{$categorydir}/{$page}.{$fileext}
[2] => category/{$catid}.{$fileext}|category/{$catid}_{$page}.{$fileext}
[3] => {$catdir}/index.{$fileext}|{$catdir}/{$page}.{$fileext}
[4] => list.php?catid={$catid}|list.php?catid={$catid}&page={$page}
[5] => list.php?catid-{$catid}.html|list.php?catid-{$catid}/page-{$page}.html
[6] => list-{$catid}-{$page}.html
[7] => {$year}/{$month}{$day}/{$contentid}.{$fileext}|{$year}/{$month}{$day}/{$contentid}_{$page}.{$fileext}
[8] => {$categorydir}/{$year}/{$month}{$day}/{$contentid}.{$fileext}|{$categorydir}/{$year}/{$month}{$day}/{$contentid}_{$page}.{$fileext}
[9] => show/{$contentid}.{$fileext}|show/{$contentid}_{$page}.{$fileext}
[10] => show.php?contentid={$contentid}|show.php?contentid={$contentid}&page={$page}
[11] => show.php?contentid-{$contentid}.html|show.php?contentid-{$contentid}/page-{$page}.html
[12] => show-{$contentid}-1.html|show-{$contentid}-{$page}.html
[13] => {$typedir}/index.{$fileext}|{$typedir}/{$page}.{$fileext}
[14] => {$typedir}.{$fileext}|{$typedir}_{$page}.{$fileext}
[15] => {$typeid}.{$fileext}|{$typeid}_{$page}.{$fileext}
[16] => list.php?typeid={$typeid}|list.php?typeid={$typeid}&page={$page}
[17] => list.php?typeid-{typeid}.html|list.php?typeid-{typeid}/page-{$page}.html
[19] => {$typedir}/{$filename}.{$fileext}
[20] => {$typedir}_{$filename}.{$fileext}
[21] => {$filename}.{$fileext}
[22] => show.php?specialid={$specialid}
[23] => show.php?specialid-{$specialid}.html
[24] => show-{$specialid}.html
[25] => show-{$id}.html
[26] => ask/list-{$catid}-{$action}-1.html|ask/list-{$catid}-{$action}-{$page}.html
[27] => {$id}.html
[28] => show.php?id={$id}
)
$M //存儲(chǔ)模塊信息,在模塊下想得到該模塊的信息 可以直接使用$M
1、變量表示
{$name} 被解析成 <?=$name?>,表示顯示變量$name的值,其中的“name”由英文字母、數(shù)字和下劃線組成首字母必須是英文字母或者下劃線。
2、常量表示
{name}被解析成<?=name?>,表示顯示常量name的值,其中的“name”由英文字母、數(shù)字和下劃線組成首字母必須是英文字母或者下劃線。
3、條件判斷
{if *} * {else} * {else} * {/if} 或者 {if *} * {/if},其中{if *}中的*就是此判斷語句的條件表達(dá)式,符合php的表達(dá)式。
{if $userid} {$username}{else} {$noname}{/if}
4、循環(huán)
{loop $a $b} * {/loop} 或者 {loop $a $b $c} * {/loop} ,{loop $a $b} * {/loop}
被解析成 <? if(is_array($a)) foreach($a AS $b) { ?> * <? } ?>
而 {loop $a $b $c} * {/loop} 則被解析成 <? if(is_array($a)) foreach($a AS $b=>$c) { ?> * <? } ?>
5.模板包含
{template 'module name','file name'}例如: {template 'phpcms','header'}表示包含模板目錄,phpcms目錄下header.html文件
建議 if 和 loop 語法應(yīng)該寫在html注釋符之間,這樣可以避免在編輯工具中難看,例如:
這樣寫 if
<!--{if $a>$b}--> <!--{else}--> <!--{/if}-->
這樣寫 loop
<!--{loop $arr $key $val}--> <!--{/loop}-->
如果您不習(xí)慣這套語法,也可以直接在模板中書寫php代碼,例如<?php echo 'Hello World!';?>
二、模板制作常用變量
常用的系統(tǒng)變量
打開文件 ./include/common.inc.php
復(fù)制代碼
代碼如下:IP //取得ip
TIME //取得時(shí)間戳,格式(1229393941 )可以通過date 函數(shù)格式化一個(gè)本地時(shí)間/日期,請(qǐng)參考php手冊(cè)
URL //取得當(dāng)前瀏覽的url地址
SITE_URL //網(wǎng)站的url地址
//以上是系統(tǒng)常量,直接調(diào)用,如()
$MODULE //系統(tǒng)模塊信息
[MODULE][phpcms] => Array
(
[module] => phpcms
[name] => Phpcms
[path] =>
[url] =>
[iscore] => 1
[version] => 1.0.0.0
)
$MODEL //模型信息
[MODEL] => Array
(
[1] => Array
(
[modelid] => 1
[name] => 新聞
[description] =>
[tablename] => news
[itemname] => 新聞
[itemunit] => 篇
[workflowid] => 1
[template_category] => category
[template_list] => list
[template_show] => show
[template_print] => print
[ishtml] => 1
[category_urlruleid] => 1
[show_urlruleid] => 7
[enablesearch] => 1
[ischeck] => 1
[isrelated] => 1
[disabled] => 0
[modeltype] => 0
)
)
$CATEGORY //欄目信息
[CATEGORY] => Array
(
[1] => Array
(
[catid] => 1
[module] => phpcms
[type] => 1
[modelid] => 0
[catname] => 網(wǎng)站介紹
[style] =>
[image] =>
[catdir] => about
[url] => /cms/phpcms_utf/about/index.html
[parentid] => 0
[arrparentid] => 0
[parentdir] =>
[child] => 1
[arrchildid] => 1,2,3,4,5
[items] => 0
[ismenu] => 0
)
)
$TYPE //類型信息
[TYPE] => Array
(
[1] => Array
(
[typeid] => 1
[module] => link
[name] => 默認(rèn)分類
[style] =>
[typedir] =>
[url] =>
)
)
$AREA //地區(qū)信息
[AREA] => Array
(
[1] => Array
(
[areaid] => 1
[name] => 北京
[style] =>
[parentid] => 0
[arrparentid] => 0
[child] => 0
[arrchildid] => 1
)
)
$URLRULE //url規(guī)則信息
[URLRULE] => Array
(
[1] => {$categorydir}/index.{$fileext}|{$categorydir}/{$page}.{$fileext}
[2] => category/{$catid}.{$fileext}|category/{$catid}_{$page}.{$fileext}
[3] => {$catdir}/index.{$fileext}|{$catdir}/{$page}.{$fileext}
[4] => list.php?catid={$catid}|list.php?catid={$catid}&page={$page}
[5] => list.php?catid-{$catid}.html|list.php?catid-{$catid}/page-{$page}.html
[6] => list-{$catid}-{$page}.html
[7] => {$year}/{$month}{$day}/{$contentid}.{$fileext}|{$year}/{$month}{$day}/{$contentid}_{$page}.{$fileext}
[8] => {$categorydir}/{$year}/{$month}{$day}/{$contentid}.{$fileext}|{$categorydir}/{$year}/{$month}{$day}/{$contentid}_{$page}.{$fileext}
[9] => show/{$contentid}.{$fileext}|show/{$contentid}_{$page}.{$fileext}
[10] => show.php?contentid={$contentid}|show.php?contentid={$contentid}&page={$page}
[11] => show.php?contentid-{$contentid}.html|show.php?contentid-{$contentid}/page-{$page}.html
[12] => show-{$contentid}-1.html|show-{$contentid}-{$page}.html
[13] => {$typedir}/index.{$fileext}|{$typedir}/{$page}.{$fileext}
[14] => {$typedir}.{$fileext}|{$typedir}_{$page}.{$fileext}
[15] => {$typeid}.{$fileext}|{$typeid}_{$page}.{$fileext}
[16] => list.php?typeid={$typeid}|list.php?typeid={$typeid}&page={$page}
[17] => list.php?typeid-{typeid}.html|list.php?typeid-{typeid}/page-{$page}.html
[19] => {$typedir}/{$filename}.{$fileext}
[20] => {$typedir}_{$filename}.{$fileext}
[21] => {$filename}.{$fileext}
[22] => show.php?specialid={$specialid}
[23] => show.php?specialid-{$specialid}.html
[24] => show-{$specialid}.html
[25] => show-{$id}.html
[26] => ask/list-{$catid}-{$action}-1.html|ask/list-{$catid}-{$action}-{$page}.html
[27] => {$id}.html
[28] => show.php?id={$id}
)
$M //存儲(chǔ)模塊信息,在模塊下想得到該模塊的信息 可以直接使用$M
相關(guān)文章
完美解決phpcms圖片太大撐破表格圖片自適應(yīng)圖片按比例縮小
下面小編就為大家?guī)硪黄昝澜鉀Qphpcms圖片太大撐破表格圖片自適應(yīng)圖片按比例縮小。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-10-18- 這篇文章主要介紹了PHPCMS v9 安全設(shè)置、防范教程,需要的朋友可以參考下2016-09-05
PHPCMS V9 全站 Sitemaps生成實(shí)現(xiàn)代碼[服務(wù)器端版]
這篇文章主要介紹了PHPCMS V9 全站 Sitemaps生成實(shí)現(xiàn)代碼[服務(wù)器端版],需要的朋友可以參考下2016-06-08phpcms內(nèi)容詳情頁(yè)只顯示日期不顯示時(shí)間的方法
這篇文章主要介紹了phpcms內(nèi)容詳情頁(yè)只顯示日期不顯示時(shí)間的方法,即格式化時(shí)間輸出的方法,需要的朋友可以參考下2015-06-19- 這篇文章主要介紹了PHPCMS制作網(wǎng)站地圖的簡(jiǎn)單方法,本文給出了操作步驟及標(biāo)簽源碼,需要的朋友可以參考下2015-06-19
- 這篇文章主要介紹了PHPCMSV9父欄目調(diào)用子欄目的方法,本文講解了在二級(jí)欄目列表頁(yè)調(diào)用、在一級(jí)欄目列表頁(yè)調(diào)用兩種方法方式,需要的朋友可以參考下2015-06-19
PHPCMS使用date函數(shù)實(shí)現(xiàn)自動(dòng)更新頁(yè)腳年月的方法
這篇文章主要介紹了PHPCMS使用date函數(shù)實(shí)現(xiàn)自動(dòng)更新頁(yè)腳年月的方法,本文主要還是可以學(xué)習(xí)到date函數(shù)的用法了,需要的朋友可以參考下2015-06-19- 這篇文章主要介紹了phpsso忘記密碼的解決辦法,本文用PHPCMS的密碼及encrypt值替換數(shù)據(jù)表解決了這個(gè)問題,方法還是挺靠譜的,只是操作要求有點(diǎn),需要的朋友可以參考下2015-06-19
- 這篇文章主要介紹了phpcms 退出無法同步通知discuz問題的解決方法,需要的朋友可以參考下2014-12-15
phpcms v9列表頁(yè)如何調(diào)用子欄目如首頁(yè)>產(chǎn)品中心>產(chǎn)品類型a
phpcms v9列表頁(yè)如何調(diào)用子欄目如:首頁(yè)>產(chǎn)品中心>產(chǎn)品類型a>產(chǎn)品類型a11,在列表頁(yè)產(chǎn)品類型a中,包括產(chǎn)品類型a1、產(chǎn)品類型a2、產(chǎn)品類型a32014-09-24