帝國CMS6.0版新增了針對會員空間信息調用的“靈動標簽函數”,使會員空間模板增加信息調用更簡單,不用寫sql查詢執行代碼。
空間的“靈動標簽函數”語法基本同靈動標簽。
空間的“靈動標簽函數”具體語法為如下:
<?php$spacesql=espace_eloop(欄目ID,顯示條數,操作類型,只顯示有標題圖片);while($spacer=$empire->fetch($spacesql)){ $spacesr=espace_eloop_sp($spacer);?>模板代碼內容<?}?>
1、espace_eloop函數的參數怎么跟靈動標簽一樣?是的,參數完全一樣,設置的內容也是一樣,支持靈動標簽的所有操作類型。
“欄目ID”:多個欄目ID、專題ID與標題分類ID可用,號格開,如'1,2'; 如果是按SQL語句調用,則此處為SQL語句。
“顯示條數”:顯示前幾條記錄。
“操作類型”:同標簽調用的操作類型。
“只顯示有標題圖片”:0為不限制,1為只顯示有標題圖片的信息。
2、$spacer變量是什么?$spacer相當于靈動標簽的“$bqr”變量:
$spacer[字段名]
3、$spacesr=espace_eloop_sp($spacer);是什么作用?“espace_eloop_sp”函數是返回特殊字段內容數組,相當于靈動標簽的$bqsr變量:
$spacesr[titleurl]:標題鏈接$spacesr[classname]:欄目名稱$spacesr[classurl]:欄目鏈接
舉例說明
例子1:用空間“靈動標簽函數”實現如下圖效果
代碼如下:
<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>
說明:調用欄目ID=2的最新5條信息。(date為時間格式化函數)
新聞熱點
疑難解答