PhpCms模板風(fēng)格:GET標(biāo)簽使用_PHPCms教程

      編輯Tag賺U幣
      教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!
      GET標(biāo)簽使用說(shuō)明:
      我們可能通過(guò)GET標(biāo)簽調(diào)用本站數(shù)據(jù)庫(kù)的信息,也可以調(diào)用其他數(shù)據(jù)庫(kù)的信息

      get 標(biāo)簽可調(diào)用本系統(tǒng)和外部數(shù)據(jù),適合熟悉SQL語(yǔ)句的人使用。注意:get標(biāo)簽屬性值必須用雙引號(hào)括起來(lái)

      1、調(diào)用本系統(tǒng)單條數(shù)據(jù),示例(調(diào)用ID為1的信息,標(biāo)題長(zhǎng)度不超過(guò)25個(gè)漢字,顯示更新日期):
      {get sql="select * from phpcms_content where contentid=1" /}
      標(biāo)題:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}

      2、調(diào)用本系統(tǒng)多條數(shù)據(jù),示例(調(diào)用欄目ID為1通過(guò)審核的10條信息,標(biāo)題長(zhǎng)度不超過(guò)25個(gè)漢字,顯示更新日期):
      {get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc" rows="10"}
      標(biāo)題:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}
      {/get}

      3、帶分頁(yè),示例(調(diào)用欄目ID為1通過(guò)審核的10條信息,標(biāo)題長(zhǎng)度不超過(guò)25個(gè)漢字,顯示更新日期,帶分頁(yè)):
      {get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc" rows="10" page="$page"}
      標(biāo)題:{str_cut($r[title], 50)} URL:{$r[url]} 更新日期:{date('Y-m-d', $r[updatetime])}
      {/get}
      分頁(yè):{$pages}

      4、自定義返回變量,示例(調(diào)用欄目ID為1通過(guò)審核的10條信息,標(biāo)題長(zhǎng)度不超過(guò)25個(gè)漢字,顯示更新日期,返回變量為 $v):
      {get sql="select * from phpcms_content where catid=1 and status=99 order by updatetime desc" rows="10" return="v"}
      標(biāo)題:{str_cut($v[title], 50)} URL:{$v[url]} 更新日期:{date('Y-m-d', $v[updatetime])}
      {/get}

      5、調(diào)用同一帳號(hào)下的其他數(shù)據(jù)庫(kù),示例(調(diào)用數(shù)據(jù)庫(kù)為bbs,分類ID為1的10個(gè)最新主題,主題長(zhǎng)度不超過(guò)25個(gè)漢字,顯示更新日期):
      {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、調(diào)用外部數(shù)據(jù),示例(調(diào)用數(shù)據(jù)源為bbs,分類ID為1的10個(gè)最新主題,主題長(zhǎng)度不超過(guò)25個(gè)漢字,顯示更新日期):
      {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}

      新建模板

      位置:模板風(fēng)格---phpcms--新建模板


      實(shí)例介紹:

      你可以選擇需要的條件創(chuàng)建,如我們以DIGG排行榜為例 如何設(shè)置DIGG排行榜的GET標(biāo)簽 ?

      注意,表的前綴不能更改,以"phpcms_"開頭,函數(shù)解析的時(shí)會(huì)自動(dòng)替換前綴

      //DIGG排行榜的GET標(biāo)簽
      <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標(biāo)簽
      <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模板

      來(lái)源:模板無(wú)憂//所屬分類:PHPCms教程/更新時(shí)間:2009-04-17
      相關(guān)PHPCms教程