一、語法
{list action=category module=share....}{/list}
簡(jiǎn)寫(3.2.19以上版本支持):{category module=share....}{/category }
二、參數(shù)介紹(紅色表示必填參數(shù),藍(lán)色表示系統(tǒng)默認(rèn)參數(shù))
| 參數(shù) | 介紹 |
|---|---|
| action | category |
| module | 共享欄目比較特殊,必須為module=share |
| site | 站點(diǎn)id,默認(rèn)當(dāng)前站點(diǎn),填寫其他站點(diǎn)id表示查詢其他站點(diǎn)的模塊數(shù)據(jù) |
| id | 欄目id,支持多個(gè)欄目以小寫分號(hào)分開,例如1,2,3,4 |
| show | 有show參數(shù)表示顯示隱藏導(dǎo)航(無論show=幾都有效) |
| pid | 當(dāng)前id下的所有下級(jí)欄目,pid只能是一個(gè)整數(shù),當(dāng)期為0時(shí)表示頂級(jí)欄目 |
| num | 表示顯示數(shù)量,只能是一個(gè)整數(shù) |
| letter | 首字母匹配的欄目 |
| mid | 按模塊查詢欄目 |
| more | 當(dāng)more=1時(shí),才顯示欄目的setting內(nèi)容和自定義擴(kuò)展屬性內(nèi)容 |
| return | 默認(rèn)返回變量為t,調(diào)用方式就是{$t.字段值}(多級(jí)list查詢必須設(shè)置return=其他字母,否則你懂得) |
三、返回變量
| 變量 | 參數(shù) |
|---|---|
| {$error} | 當(dāng)查詢不到數(shù)據(jù)時(shí),會(huì)返回錯(cuò)誤信息,調(diào)試模板時(shí)很有用哦(寫在list標(biāo)簽以外) |
| {$count} | 當(dāng)前查詢的記錄,當(dāng)存在分頁時(shí),表示當(dāng)前頁的記錄數(shù)(寫在list標(biāo)簽以外) |
| {$key} | 當(dāng)前記錄指針位置,從0開始(寫在list標(biāo)簽以內(nèi)) |
| 當(dāng)存在return=字母時(shí),以上變量都要寫成這種格式{$變量_字母},例如{list ...reutrn=a}時(shí),變量格式{$key_a} | |
| {$is_first} | 判斷是否第一條,{if $is_first}第一條{/if} |
| {$is_last} | 判斷是否最后一條,{if $is_last}最后一條{/if} |
四、顯示字段
{$t.字段名稱}或者{$t['字段名稱']}
五、相關(guān)例子
1、查詢共享模塊的所有頂級(jí)欄目
{list action=category module=share pid=0}
欄目名稱{$t.name}
欄目地址{$t.url}
{/list}2、查詢共享模塊的指定id為1,2,3,4的欄目
{list action=category module=share id=1,2,3,4}
欄目名稱{$t.name}
欄目地址{$t.url}
{/list}3、兩級(jí)循環(huán)顯示欄目(先循環(huán)父欄目,再循環(huán)其子欄目)
{list action=category module=share pid=0 return=c1}
我是父欄目:{$c1.name}<br>
{if $c1.child}
{list action=category module=share pid=$c1.id return=c2}
我是{$c1.name}的子欄目:{$c2.name}<br>
{if $c2.child}
{list action=category module=share pid=$c2.id return=c3}
我是{$c2.name}的子欄目:{$c3.name}<br>
{/list}
{/if}
{/list}
{/if}
{/list}如果有三級(jí)以上欄目,以此類推,不再舉例了,我相信你的能力
文檔最后更新時(shí)間:2018-09-29 13:37:12