帝国CMS内容页根据Tag调用相关文章 不指定

郝聪 , 2019/06/11 22:45 , 建站优化 , 评论(0) , 阅读(7226) , Via 本站原创 | |


更多



 ä»¥ä¸‹ä»£ç å†™å…¥/e/class/userfun.php文件内

XML/HTML代码
        
  1. function user_otherlink($limit=5){  
  2.     
  3.         global $dbtbpre,$empire,$navinfor,$class_r;  
  4.     
  5.     if($navinfor[infotags]){  
  6.     
  7.             $classid=(int)$classid;  
  8.     
  9.         $limit=(int)$limit;  
  10.     
  11.         $tbname=$class_r[$navinfor[classid]][tbname];  
  12.     
  13.         $tagarr=explode(",",$navinfor[infotags]);  
  14.     
  15.         $arr=array();  
  16.     
  17.         $num=ceil($limit/count($tagarr));  
  18.     
  19.         foreach($tagarr as $k=>$v){  
  20.     
  21.                         if(count($tagarr)==$k+1){  
  22.     
  23.                                 $num=$limit-count($arr);  
  24.     
  25.                         }else{  
  26.     
  27.                                 if($i<$num){  
  28.     
  29.                                         $num=ceil(($limit-count($arr))/count($tagarr));  
  30.     
  31.                                 }                  
  32.     
  33.                         }  
  34.     
  35.             $t=$empire->fetch1("select tagid,num from {$dbtbpre}enewstags where tagname='$v'");  
  36.     
  37.                         if($t[tagid]){  
  38.     
  39.                                 $sql=$empire->query("select id from {$dbtbpre}enewstagsdata where tagid=$t[tagid]");  
  40.     
  41.                                 $i=0;  
  42.     
  43.                                 while($s=$empire->fetch($sql)){  
  44.     
  45.                                         if(in_array($s[id],$arr)||$s[id]==$navinfor[id]){  
  46.     
  47.                                                 continue;  
  48.     
  49.                                         }else{  
  50.     
  51.                                                 $arr[]=$s[id];  
  52.     
  53.                                                 $i++;  
  54.     
  55.                                         }  
  56.     
  57.                                         if($i==$num){  
  58.     
  59.                                                 break;  
  60.     
  61.                                         }  
  62.     
  63.                                         if(count($arr)==$limit){  
  64.     
  65.                                                 break 2;  
  66.     
  67.                                         }  
  68.     
  69.                                 }  
  70.     
  71.                                 if($t[num]>$num){  
  72.     
  73.                                         $linshi=$t[tagid];  
  74.     
  75.                                 }  
  76.     
  77.                         }   
  78.     
  79.         }  
  80.     
  81.         if(count($arr)>0){  
  82.     
  83.                         $inid=implode(",",$arr);  
  84.     
  85.                         if(count($arr)<$limit&&$linshi){  
  86.     
  87.                                 $sql=$empire->query("select id from {$dbtbpre}enewstagsdata where tagid=$linshi and id not in($inid)");  
  88.     
  89.                                 while($s=$empire->fetch($sql)){  
  90.     
  91.                                         $arr[]=$s[id];  
  92.     
  93.                                         if(count($arr)==$limit){  
  94.     
  95.                                                 break;  
  96.     
  97.                                         }  
  98.     
  99.                                 }  
  100.     
  101.                         }  
  102.     
  103.                         $inid=implode(",",$arr);  
  104.     
  105.                         $str="";  
  106.     
  107.                         $news=$empire->query("select id,title,titleurl,titlepic,newstime from {$dbtbpre}ecms_{$tbname} where id in($inid)");  
  108.     
  109.                         while($n=$empire->fetch($news)){  
  110.     
  111.                                 //用date参数格式化日期  
  112.     
  113.                                 $now = $n[newstime];  
  114.     
  115.                                 $str.='<li><span class="point"></span><a href="'.$n[titleurl].'">'.$n[title].'</a><div>'.date("m-d",$now).'</div></li>';  
  116.     
  117.                         }          
  118.     
  119.                 }  
  120.     
  121.         return $str;  
  122.     
  123.            }  
  124.     
  125. }  

在内容页模板用以下代码调用:

XML/HTML代码
        
  1. <?=user_otherlink(5)?>  

5为显示数量,可自行修改

相关日志
帝国CMS调用自定义列表名称的方法
帝国CMS获取当前自定义列表的listid
帝国CMS自定义列表调用当天发布的信息
帝国CMS自定义列表的排序newstime、onclick、plnum
帝国CMS自定义列表多表联合查询的方法
帝国CMS用自定义列表来制作带分页的专题列表页
帝国CMS提示Fatal error:Allowed memory size of的解决方法
帝国CMS内容关键字替换功能如何避免将Alt和title中的关键词替换成链接
帝国cms灵动标签中调用栏目名称和别名的方法
帝国CMS的Tag页面使用like调用相关tags的方法
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]