之前本人也发过求助帖,有热心的朋友告知了办法,但是苦于自己不懂php,不懂编程,只能在网上搜索现成的。
但,关于这方面的现成文章还真是没有,或者说很难找到。
皇天不负有心人,就在昨天终于找到了。
可是代码要收费,30积分,也就是30大洋,咬咬牙支付宝充值买了。
现在免费分享给有需要的朋友。
以下是具体实现过程:
以下代码放到/e/class/userfun.php里!
<?php
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 from {$dbtbpre}ecms_{$tbname} where id in($inid)");
while($n=$empire->fetch($news)){
$str.='<li><a href="'.$n[titleurl].'">'.$n[title].'</a></li>';
}
}
return $str;
}
}
?>
内容页模板用以下代码调用:5为显示数量 自己改
<?=user_otherlink(5)?>
回复列表
19.
有个问题,这个会让网页错位,不知道是不是只有我一个人出现;调用出来的相关文章列表,会让网页错位;但是我把它调用出来的那段相关文章代码,直接放到模板里,网页又是正常的,怎么解释!!
这是调用出来的链接<a href="/qcpz/whqc/2015-12-31/45.html">蒜香酱油肉丝拌面</a>
<a href="/qcpz/whqc/2015-12-31/46.html">奶油彩绘蛋糕卷</a>
<a href="/qcpz/whqc/2015-12-31/73.html">足料沙茶面</a>
<a href="/qcpz/nhec/2015-12-31/84.html">香菇烧卖</a>
$str.='<a href="'.$n[titleurl].'">'.$n[title].'</a>';
这是代码
24.
tags就是为相关链接而生。keyboard是seo的 。支持,感谢!
32.
楼主,我照你方式弄了,页面上面没有任何信息,不知道什么情况
33.
股指期货配资http://www.jinniuzhi.com