?以下代码写入/e/class/userfun.php文件内
XML/HTML代码
- ????
- function?user_otherlink($limit=5){?? ????
- ????????global?$dbtbpre,$empire,$navinfor,$class_r;?? ????
- ????if($navinfor[infotags]){?? ????
- ????????????$classid=(int)$classid;?? ????
- ????????$limit=(int)$limit;?? ????
- ????????$tbname=$class_r[$navinfor[classid]][tbname];?? ????
- ????????$tagarr=explode(",",$navinfor[infotags]);?? ????
- ????????$arr=array();?? ????
- ????????$num=ceil($limit/count($tagarr));?? ????
- ????????foreach($tagarr?as?$k=>$v){?? ????
- ????????????????????????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,newstime?from?{$dbtbpre}ecms_{$tbname}?where?id?in($inid)");?? ????
- ????????????????????????while($n=$empire->fetch($news)){?? ????
- ????????????????????????????????//用date参数格式化日期?? ????
- ????????????????????????????????$now?=?$n[newstime];?? ????
- ????????????????????????????????$str.='
- <>.$n[titleurl].'">'.$n[title].'a><div>'.date("m-d",$now).'div>li>';??
???? - ????????????????????????}?????????? ????
- ????????????????}?? ????
- ????????return?$str;?? ????
- ???????????}?? ????
- }??
在内容页模板用以下代码调用:
XML/HTML代码
- ????
- =user_otherlink(5)?>??
5为显示数量,可自行修改