帝国cms关键字tags相关文章调用标签,绝对好用!

2019-03-2616:25:35网站建设与开发Comments2,901 views字数 2616阅读模式
此代码有重复文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10384.html

<?
$taginfo_r=explode(',',$navinfor['infotags']);
if(is_array($taginfo_r)){
foreach($taginfo_r as $tagname){
if($tagname){
$tagr=$empire->fetch1("select tagid from {$dbtbpre}enewstags where tagname='$tagname' limit 1");
if($tagr['tagid']){
$tsql=$empire->query("select * from {$dbtbpre}enewstagsdata where tagid=".$tagr['tagid']."");
while($tr=$empire->fetch($tsql)){
if($tr['id']==$navinfor['id'] && $tr['classid']==$navinfor['classid']){
continue;
}
if(empty($class_r[$tr['classid']]['tbname']))
{
continue;
}
$infor=$empire->fetch1("select id,classid,shopname,shopurl,newspath,filename,groupid,titleurl,title from {$dbtbpre}ecms_".$class_r[$tr['classid']]['tbname']." where id=".$tr[id]." limit 1");
$ti_url=sys_ReturnBqTitleLink($infor);
?>
<div class="listsite">
<ul>
<li><a href="<?=$ti_url?>/" class="webname2" title="<?=$infor['title']?><?=$infor['shopname']?>"><?=$infor['title']?><?=$infor['shopname']?></a></li>
<li class="li3"></li>
</ul>
</div>
<?
}
}
}
}
}
?>

此代码把当前文章也包含了
<!--内容页调用标签开始-->
<?
$a="$navinfor[infotags]";
$str=str_replace(',', ',', $a);
$tag='';
$t= explode(",", $str);文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10384.html

for($i=0;$i<count($t);$i++)
{
if($t[$i])
{
?>
[e:loop={"SELECT tagid FROM phome_enewstags WHERE tagname = '".$t[$i]."'",1,24,0}]文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10384.html

[tagsinfo]$bqr[tagid],10,32,21,0,0[/tagsinfo]文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10384.html

[/e:loop]
<?
}
}
?>文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10384.html

<!--内容页调用标签结束-->

 文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10384.html

根据Tags 调用相关文章,绝对好用!文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10384.html

以下是具体实现过程:
以下代码放到/e/class/userfun.php里!文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10384.html


<?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;
}
}
?>文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10384.html


内容页模板用以下代码调用:5为显示数量 自己改文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10384.html


<?=user_otherlink(5)?>

文章源自菜鸟学院-https://www.cainiaoxueyuan.com/cms/10384.html
  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/cms/10384.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定