發(fā)布時間:2020-06-16
欄目:其他
什么是標簽調(diào)用?
標簽調(diào)用是根據(jù)調(diào)用條件(condition)從數(shù)據(jù)表(table)讀取調(diào)用數(shù)量(pagesize)條數(shù)據(jù),并按排序方式(order)排序,最終通過標簽模板的布局輸出數(shù)據(jù)。
可以看出,標簽的工作分兩個部分,一是讀取數(shù)據(jù),二是顯示數(shù)據(jù)。
標簽函數(shù)原型
標簽函數(shù)保存于 include/tag.func.php
tag($parameter, $expires = 0)
$parameter 表示傳遞給tag函數(shù)的字符串,系統(tǒng)自動將其轉(zhuǎn)換為多個變量。
例如傳遞 table=destoon&pagesize=10&hello=world
系統(tǒng)相當于得到:
$table = 'destoon';
$pagesize = 10;
$hello = 'world';
三個變量
$expires 表示標簽緩存過期時間
>0 緩存$expires秒;0 - 系統(tǒng)默認標簽緩存時間;-1 - 不緩存;-2 - 緩存SQL結(jié)果;
一般情況保持默認不需要傳遞。
數(shù)據(jù)讀取過程
例如以下標簽:
<!--{tag("moduleid=5&condition=status=3&order=addtime desc&pagesize=10")}-->
會被轉(zhuǎn)換為如下的SQL語句:
SELECT *
FROM destoon_sell
WHERE status=3
ORDER BY addtime DESC
LIMIT 0,10
讀出的數(shù)據(jù)會保存在 $tags 數(shù)組里
通常情況下不需要寫table=xxx,應該寫moduleid=模塊ID,系統(tǒng)會自動對應模塊的表
數(shù)據(jù)顯示過程
1、通過標簽模板顯示
傳遞&template=abc給標簽函數(shù),例如:
<!--{tag("moduleid=...&template=abc")}-->
默認的標簽模板保存在模板目錄/tag/目錄里,例如&template=abc將調(diào)用模板目錄/tag/abc.htm模板來顯示數(shù)據(jù)。
如果標簽模板存放于其他目錄,例如def,則傳遞&dir=def&template=abc,系統(tǒng)將調(diào)用模板目錄/def/abc.htm模板Destoon批量刪除關(guān)鍵詞 。
2、直接在模板里循環(huán)數(shù)據(jù)
<!--{php $tags=tag("moduleid=...&template=null");}-->
此寫法傳遞標簽模板為null,并且直接返回數(shù)據(jù)給$tags數(shù)組,此時可以直接在模板里循環(huán)了。
以下為一個完整的示例:
<!--{php $tags=tag("moduleid=...&template=null");}-->
Destoon采集軟件{loop $tags $t}
...
{/loop}
第一種寫法一般用于多次調(diào)用的數(shù)據(jù)Destoon批量更新文章 ,第二種寫法一般用于只調(diào)用一次的數(shù)據(jù)。
文章地址:http://www.brucezhang.com/article/other/DESTOONBBbqtagtysc.html