帝國CMS6.0版新增了針對會員空間信息調(diào)用的“靈動標(biāo)簽函數(shù)”,使會員空間模板增加信息調(diào)用更簡單,不用寫sql查詢執(zhí)行代碼。
空間的“靈動標(biāo)簽函數(shù)”語法基本同靈動標(biāo)簽,大家回顧下靈動標(biāo)簽語法: 點(diǎn)擊這里查看:http://www.oldmartcafe.com/doc/ecmsedu/base/mbzz/html/sysbq.html#eloop
空間的“靈動標(biāo)簽函數(shù)”具體語法為如下:
<?php $spacesql=espace_eloop(欄目ID,顯示條數(shù),操作類型,只顯示有標(biāo)題圖片); while($spacer=$empire->fetch($spacesql)) { $spacesr=espace_eloop_sp($spacer); ?> 模板代碼內(nèi)容 <? } ?> |
1、espace_eloop函數(shù)的參數(shù)怎么跟靈動標(biāo)簽一樣?是的,參數(shù)完全一樣,設(shè)置的內(nèi)容也是一樣,支持靈動標(biāo)簽的所有操作類型。 “欄目ID”:多個欄目ID、專題ID與標(biāo)題分類ID可用,號格開,如'1,2'; 如果是按SQL語句調(diào)用,則此處為SQL語句。 “顯示條數(shù)”:顯示前幾條記錄。 “操作類型”:同標(biāo)簽調(diào)用的操作類型。 “只顯示有標(biāo)題圖片”:0為不限制,1為只顯示有標(biāo)題圖片的信息。
2、$spacer變量是什么?$spacer相當(dāng)于靈動標(biāo)簽的“$bqr”變量: $spacer[字段名]
3、$spacesr=espace_eloop_sp($spacer);是什么作用?“espace_eloop_sp”函數(shù)是返回特殊字段內(nèi)容數(shù)組,相當(dāng)于靈動標(biāo)簽的$bqsr變量: $spacesr[titleurl]:標(biāo)題鏈接 $spacesr[classname]:欄目名稱 $spacesr[classurl]:欄目鏈接
舉例說明 例子1:用空間“靈動標(biāo)簽函數(shù)”實(shí)現(xiàn)如下圖效果
 實(shí)現(xiàn)代碼為如下:
<table width="380" border="0" cellpadding="3" cellspacing="1" bgcolor="#96C8F1" align="center"> <tr> <td background="template/default/images/bg_title_sider.gif"><b>最新新聞</b></td> </tr> <tr> <td bgcolor="#FFFFFF"> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <?php $spacesql=espace_eloop(2,5,0,0); while($spacer=$empire->fetch($spacesql)) { $spacesr=espace_eloop_sp($spacer); ?> <tr> <td height="25"> <img src="template/default/images/li.gif" width="15" height="10"><a href="<?=$spacesr[titleurl]?>" target="_blank"><?=$spacer[title]?></a> (<?=date('Y-m-d',$spacer[newstime])?>) </td> </tr> <? } ?> </table> </td> </tr> </table> |
說明:調(diào)用欄目ID=2的最新5條信息。(date為時間格式化函數(shù))
例子2:用空間“靈動標(biāo)簽函數(shù)”實(shí)現(xiàn)如下圖效果
 實(shí)現(xiàn)代碼為如下:
<table width="100%" border="0" cellpadding="3" cellspacing="1" bgcolor="#96C8F1" align="center"> <tr> <td background="template/default/images/bg_title_sider.gif"><b>圖片新聞</b></td> </tr> <tr> <td bgcolor="#FFFFFF"> <table width="100%" border="0" cellspacing="1" cellpadding="3"> <tr> <?php $spacesql=espace_eloop(2,4,0,1); while($spacer=$empire->fetch($spacesql)) { $spacesr=espace_eloop_sp($spacer); ?> <td height="25" align="center"> <a href="<?=$spacesr[titleurl]?>" target="_blank"><img src="<?=$spacer[titlepic]?>" width="108" height="72" border="0"></a> <br> <a href="<?=$spacesr[titleurl]?>" target="_blank"><?=esub($spacer[title],20)?></a> </td> <? } ?> </tr> </table> </td> </tr> </table> |
說明:調(diào)用帶標(biāo)題圖片的最新4條信息。(esub為截取字?jǐn)?shù)函數(shù)) |
|
|
|