顯示一周內信息點擊排行
[e:loop={'news',10,18,0,'newstime>UNIX_TIMESTAMP()-86400*7','onclick desc'}]
<a href="<?=$bqsr[titleurl]?>" target="_blank"><?=$bqr[title]?></a><br>
[/e:loop]
發個靈動標簽技巧,多少天內的信息顯示new字樣
<table>
[e:loop={欄目ID,顯示條數,操作類型,只顯示有標題圖片}]
<?
$newimg="";
if(time()-$bqr[truetime]<=3*24*3600)
{
$newimg="<img src='New圖片地址'>";
}
?>
<tr><td>
<a href="<?=$bqsr[titleurl]?>" target="_blank"><?=esub($bqr[title],36)?></a><?=$newimg?>
</td></tr>
[/e:loop]
</table>
按表隨機調用: [ecmsinfo]"select * from phome_ecms_news order by rand() desc limit 6 ",6,18,0,24,2,0[/ecmsinfo]
隨機調用本欄目:[ecmsinfo]"select * from phome_ecms_news where classid='$GLOBALS[navclassid]' order by rand() desc limit 6",6,18,0,24,2,0[/ecmsinfo]
其中:news為表名,兩個6表示調用的數量為6條,18表示標題取18個字符,第一個0表示不顯示欄名名,隨機調用的操作類型固定為24,2表示模板ID,第二個0標題圖片不存在也調用
<?php
$randnum=10; //隨機數量
$randids='';
$randdh='';
for($i=1;$i<=$randnum;$i++)
{
$randids.=$randdh.rand(1,100000); //1為最小ID,100000為最大ID
$randdh=',';
}
?>
[e:loop={欄目ID,顯示條數,操作類型,只顯示有標題圖片,"id in ($randids)"}]
模板代碼內容
[/e:loop]
另外,在論壇在搜索,得知隨機調用某欄目應該是以下幾種:
[ecmsinfo]"select * from phome_ecms_article where classid='ID名' order by rand() desc limit 6",6,18,0,24,2,0[/ecmsinfo]
[ecmsinfo]"select * from phome_ecms_news where classid in (id1,id2,id3....) order by rand() desc limit 6 ",6,18,0,24,2,0[/ecmsinfo]
……
然而,自己測試時,卻發現不能成功,至於什么原因就不清楚了,
調用標題包含“cms”的新聞
[e:loop={'news',10,18,0,"title like '%cms%'",''}]
<a href="<?=$bqsr[titleurl]?>" target="_blank"><?=$bqr[title]?></a><br>
[/e:loop]
【新手復制模仿即可】
調用論壇最新10個帖子:
<DIV>
<UL>
[e:loop={"select tid,subject from cdb_threads order by tid desc limit 10",10,24,0}]
<li><a href="http://www.nuopu.net/bbs/viewthread.php?tid=<?=$bqr[tid]?>" target="_blank"><?=sub($bqr[subject],0,40,false)?></a></li>
[/e:loop]
</UL>
</DIV>
給不懂得sql的新手的翻譯說明:
select tid,subject from cdb_threads order by tid desc limit 10",10,24,0
這句話的意思是:
從 cdb_threads 這個數據表中 選擇 tid,subject 兩個數據,按照tid順序排列10個
<li><a href="http://www.paomei.net/bbs/viewthread.php?tid= <?=$bqr[tid]?> " target="_blank"> <?=sub($bqr[subject],0,40,false)?> </a></li>
<?=$bqr[tid]?> 意思是展示 cdb_threads 這個數據表中的 tid 這個字段,
<?=sub($bqr[subject],0,40,false)?> 意思是展示 cdb_threads 這個數據表中的 subject 這個字段,並且截取40個字符,也就是20個漢字
以上的解釋夠通俗易懂的了吧?看不懂代碼沒關系,把那些< >當中的看不懂的東西,就當做一個你不認識的漢字看待,復制粘貼即可
調用論壇10個精華帖子,按順序排列:
<DIV>
<UL>
[e:loop={"select tid,subject from cdb_threads where digest <>0 order by tid desc limit 10",10,24,0}]
<li><a href="http://www.99800.cn/bbs/viewthread.php?tid=<?=$bqr[tid]?>" target="_blank"><?=sub($bqr[subject],0,40,false)?></a></li>
[/e:loop]
</UL>
</DIV>
跟上面一樣,不同的就是加上了 where digest <>0 也就是選擇帶有digest的帖子;
調用論壇10個訪問最多的帖子,按訪問順序排列:
<DIV>
<UL>
[e:loop={"select tid,subject from cdb_threads order by views desc limit 10",10,24,0}]
<li><a href="http://www.qikuai.net/bbs/viewthread.php?tid=<?=$bqr[tid]?>" target="_blank"><?=$bqr[subject]?></a></li>
[/e:loop]
</UL></DIV>
論壇排行:
<DIV>
<UL>
[e:loop={"select fid,name from cdb_forums order by threads desc limit 10",10,24,0}]
<li><a href="http://www.010k.net/bbs/forumdisplay.php?fid=<?=$bqr[fid]?>" target="_blank"> <?=$bqr[name]?> </a></li>
[/e:loop]
</UL></DIV>
fid,name,threads 是dz論壇數據表cdb_forums 中的三個字段,分別代表:論壇板塊id,論壇板塊名,論壇板塊內的帖子
所以以上代碼的意思就是:
用靈動標簽調用cdb_forums這個數據表中的id,name這兩個數據,並且按照threads的多少排列;調用的內容fid賦給了 <a href="http://www.xxx.com/bbs/forumdisplay.php?fid=<?=$bqr
[fid]?>" 當中的fid,調用的字段name賦給了<?=$bqr[name]?> ,即前台模版中顯示的板塊名字
通過以上三個簡單的例子,大致可以明白,靈動標簽可以直接調用數據庫里的字段,需要用一個sql語句讀取這個字段,如果出現錯誤的話,最常見的一種原因就是數據表不存在,也就是你的數據表沒設定好,一般默認安裝的discuz論壇不用修改上面的代碼。
以上是我個人的經驗,本人不懂得sql語言,也不懂php語言,就會一點簡單的html和簡單的英語,參考了以下幾個帖子,在此對表示感謝!
http://bbs.phome.net/ShowThread/?threadid=29390&forumid=35 【這個是講解用萬能標簽調用的】
http://bbs.phome.net/ShowThread/?threadid=80318&forumid=13
好像還看了其他的,反正我是使用帝國論壇搜索相關的帖子一個一個看過來的,然后一遍一遍的嘗試,終於搞定了這些東西
[e:loop={"select uid,username from uchome_space order by credit desc limit 9",9,24,0}]
<div><a href="http://www.jqap.com/home/space.php?uid=<?=$bqr[uid]?>" target="_blank"><img src="http://www.xxx.com/ucenter/avatar.php?uid=<?=$bqr[uid]?
>&size=small&type=real" width="48px" height="48px" ></a></div>
<div><a href="http://www.jqap.com/home/space.php?uid=<?=$bqr[uid]?>" target="_blank"><?=$bqr[username]?></a></div>
[/e:loop]
靈動標簽調用uchome顯示會員頭像的代碼我也分享出來了
一夜沒睡覺,就研究出這點東西
熱門會員頭像,最新日志,最新話題,記錄,代碼都差不多,自己替換一些字段就行了
基本上是discuz uchome 能調用的我都調用了
下面這個為調用論壇最新信息
[ecmsinfo]'select subject as title,tid as id from cdb_threads order by tid desc limit 10',0,30,0,24,7,0[/ecmsinfo]
其他的參數就不多講了
帝國的教材很詳細
調用特定主題的帖子信息
[ecmsinfo]'select subject as title,tid as id from discuz5.cdb_threads where fid=這里為要調用的主題帖子內容的FID order by tid desc limit 10',0,30,0,24,7,0[/ecmsinfo]
調用多個板塊的帖子
[ecmsinfo]'select subject as title,tid as id from discuz5.cdb_threads where fid=數字 or fid=數字 order by tid desc limit 10',0,30,0,24,7,0[/ecmsinfo]