以下是具体实现过程:
以下代码放到/e/class/userfun.php里!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
if(count($tagarr)==$k+1){ $num=$limit-count($arr); }else{ if($i<$num){ $num=ceil(($limit-count($arr))/count($tagarr)); } } $t=$empire->fetch1("select tagid,num from {$dbtbpre}enewstags where tagname='$v'"); if($t[tagid]){ $sql=$empire->query("select id from {$dbtbpre}enewstagsdata where tagid=$t[tagid]"); $i=0; while($s=$empire->fetch($sql)){ if(in_array($s[id],$arr)||$s[id]==$navinfor[id]){ continue; }else{ $arr[]=$s[id]; $i++; } if($i==$num){ break; } if(count($arr)==$limit){ break 2; } } if($t[num]>$num){ $linshi=$t[tagid]; } } } if(count($arr)>0){ $inid=implode(",",$arr); if(count($arr)<$limit&&$linshi){ $sql=$empire->query("select id from {$dbtbpre}enewstagsdata where tagid=$linshi and id not in($inid)"); while($s=$empire->fetch($sql)){ $arr[]=$s[id]; if(count($arr)==$limit){ break; } } } $inid=implode(",",$arr); $str=""; $news=$empire->query("select id,title,titleurl,titlepic from {$dbtbpre}ecms_{$tbname} where id in($inid)"); while($n=$empire->fetch($news)){ $str.=' '.$n[title].' '; } } return $str; } } ?> |
内容页模板用以下代码调用:5为显示数量 自己改
1 2 3 4 5 6 7 8 |
while($n=$empire->fetch($news)){ $now = $n[newstime]; $str.=' '.$n[title].''.date("Y-m-d", $now).' '; } |