PhpCms模板風格:GET標簽使用_PHPCms教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
GET標簽使用說明:
我們可能通過GET標簽調用本站數(shù)據(jù)庫的信息,也可以調用其他數(shù)據(jù)庫的信息
get 標簽可調用本系統(tǒng)和外部數(shù)據(jù),適合熟悉SQL語句的人使用。注意:get標簽屬性值必須用雙引號括起來
1、調用本系統(tǒng)單條數(shù)據(jù),示例(調用ID為1的信息,標題長度不超過25個漢字,顯示更新日期):
{get sql="select * from phpcms_content where contentid=1" /}
標題:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}
2、調用本系統(tǒng)多條數(shù)據(jù),示例(調用欄目ID為1通過審核的10條信息,標題長度不超過25個漢字,顯示更新日期):
{get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc" rows="10"}
標題:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}
{/get}
3、帶分頁,示例(調用欄目ID為1通過審核的10條信息,標題長度不超過25個漢字,顯示更新日期,帶分頁):
{get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc" rows="10" page="$page"}
標題:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}
{/get}
分頁:{$pages}
4、自定義返回變量,示例(調用欄目ID為1通過審核的10條信息,標題長度不超過25個漢字,顯示更新日期,返回變量為 $v):
{get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc" rows="10" return="v"}
標題:{str_cut($v[title], 50)} URL:{$v[url]} 更新日期:{date('Y-m-d', $v[updatetime])}
{/get}
5、調用同一帳號下的其他數(shù)據(jù)庫,示例(調用數(shù)據(jù)庫為bbs,分類ID為1的10個最新主題,主題長度不超過25個漢字,顯示更新日期):
{get dbname="bbs" sql="select * from cdb_threads where fid=1 order by dateline desc" rows="10"}
主題:{str_cut($r[subject], 50)} URL:http://bbs.phpcms.cn/viewthread.php?tid={$r[tid]} 更新日期:{date('Y-m-d', $r[dateline])}
{/get}
6、調用外部數(shù)據(jù),示例(調用數(shù)據(jù)源為bbs,分類ID為1的10個最新主題,主題長度不超過25個漢字,顯示更新日期):
{get dbsource="bbs" sql="select * from cdb_threads where fid=1 order by dateline desc" rows="10"}
主題:{str_cut($r[subject], 50)} URL:http://bbs.phpcms.cn/viewthread.php?tid={$r[tid]} 更新日期:{date('Y-m-d', $r[dateline])}
{/get}
新建模板
位置:模板風格---phpcms--新建模板

實例介紹:
你可以選擇需要的條件創(chuàng)建,如我們以DIGG排行榜為例 如何設置DIGG排行榜的GET標簽 ?
注意,表的前綴不能更改,以"phpcms_"開頭,函數(shù)解析的時會自動替換前綴
//DIGG排行榜的GET標簽
<ol>
{get sql="SELECT * FROM phpcms_content c,phpcms_digg d WHERE c.contentid=d.contentid AND c.status=99 ORDER BY d.supports DESC" rows="8"}
<li><span>{$r[supports]}</span><a href="{$r[url]}">{str_cut($r[title], 88)}</a></li>
{/get}
</ol>
//DIGG排行榜的GET標簽
<ol>
{get sql="SELECT * FROM phpcms_content c,phpcms_digg d WHERE c.contentid=d.contentid AND c.status=99 ORDER BY d.supports DESC" rows="8"}
<li><span>{$r[supports]}</span><a href="{$r[url]}">{str_cut($r[title], 88)}</a></li>
{/get}
</ol>
我們可能通過GET標簽調用本站數(shù)據(jù)庫的信息,也可以調用其他數(shù)據(jù)庫的信息
get 標簽可調用本系統(tǒng)和外部數(shù)據(jù),適合熟悉SQL語句的人使用。注意:get標簽屬性值必須用雙引號括起來
1、調用本系統(tǒng)單條數(shù)據(jù),示例(調用ID為1的信息,標題長度不超過25個漢字,顯示更新日期):
{get sql="select * from phpcms_content where contentid=1" /}
標題:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}
2、調用本系統(tǒng)多條數(shù)據(jù),示例(調用欄目ID為1通過審核的10條信息,標題長度不超過25個漢字,顯示更新日期):
{get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc" rows="10"}
標題:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}
{/get}
3、帶分頁,示例(調用欄目ID為1通過審核的10條信息,標題長度不超過25個漢字,顯示更新日期,帶分頁):
{get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc" rows="10" page="$page"}
標題:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}
{/get}
分頁:{$pages}
4、自定義返回變量,示例(調用欄目ID為1通過審核的10條信息,標題長度不超過25個漢字,顯示更新日期,返回變量為 $v):
{get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc" rows="10" return="v"}
標題:{str_cut($v[title], 50)} URL:{$v[url]} 更新日期:{date('Y-m-d', $v[updatetime])}
{/get}
5、調用同一帳號下的其他數(shù)據(jù)庫,示例(調用數(shù)據(jù)庫為bbs,分類ID為1的10個最新主題,主題長度不超過25個漢字,顯示更新日期):
{get dbname="bbs" sql="select * from cdb_threads where fid=1 order by dateline desc" rows="10"}
主題:{str_cut($r[subject], 50)} URL:http://bbs.phpcms.cn/viewthread.php?tid={$r[tid]} 更新日期:{date('Y-m-d', $r[dateline])}
{/get}
6、調用外部數(shù)據(jù),示例(調用數(shù)據(jù)源為bbs,分類ID為1的10個最新主題,主題長度不超過25個漢字,顯示更新日期):
{get dbsource="bbs" sql="select * from cdb_threads where fid=1 order by dateline desc" rows="10"}
主題:{str_cut($r[subject], 50)} URL:http://bbs.phpcms.cn/viewthread.php?tid={$r[tid]} 更新日期:{date('Y-m-d', $r[dateline])}
{/get}
新建模板
位置:模板風格---phpcms--新建模板

實例介紹:
你可以選擇需要的條件創(chuàng)建,如我們以DIGG排行榜為例 如何設置DIGG排行榜的GET標簽 ?
注意,表的前綴不能更改,以"phpcms_"開頭,函數(shù)解析的時會自動替換前綴
//DIGG排行榜的GET標簽
<ol>
{get sql="SELECT * FROM phpcms_content c,phpcms_digg d WHERE c.contentid=d.contentid AND c.status=99 ORDER BY d.supports DESC" rows="8"}
<li><span>{$r[supports]}</span><a href="{$r[url]}">{str_cut($r[title], 88)}</a></li>
{/get}
</ol>
//DIGG排行榜的GET標簽
<ol>
{get sql="SELECT * FROM phpcms_content c,phpcms_digg d WHERE c.contentid=d.contentid AND c.status=99 ORDER BY d.supports DESC" rows="8"}
<li><span>{$r[supports]}</span><a href="{$r[url]}">{str_cut($r[title], 88)}</a></li>
{/get}
</ol>
相關PHPCms教程:
- 相關鏈接:
- 教程說明:
PHPCms教程-PhpCms模板風格:GET標簽使用
。