搜一搜

帝国cms相关内容调用

在线评论 01329
古典技术
作者:古典

发布时间:2021-07-25来源:古典技术网

自定义函数user_OtherLink 来进行相关内容的调用,通过tags来获取代码如下:

一、自定义函数

自定义函数user_OtherLink ,将此函数放入 /e/class/userfun.php 文件中。


//根据tag获取相关信息

function user_OtherLink($num,$classid=0,$mid=0){

global $dbtbpre,$empire,$navinfor,$class_r;

if(empty($navinfor['infotags'])){

return '暂无相关信息';

}

if($mid&&$classid&&$class_r[$classid]['modid']!=$mid){

return '暂无相关信息';

}

$tr=$empire->fetch1("select otherlinktemp,otherlinktempsub,otherlinktempdate from ".GetTemptb("enewspubtemp")." limit 1");

$temp_r=explode("[!--empirenews.listtemp--]",$tr['otherlinktemp']);

$str='';

$tagsql=$empire->query("select * from {$dbtbpre}enewstagsdata where id='$navinfor[id]' and classid='$navinfor[classid]'");

$i=0;

$isprint=array();

while($tagr=$empire->fetch($tagsql)){

if($i>=$num){

break;

}

$gsql=$empire->query("select * from {$dbtbpre}enewstagsdata where tagid='$tagr[tagid]'");

while($gr=$empire->fetch($gsql)){

$myprint='id'.$gr['id'].'class'.$gr['classid'];

if(array_search($myprint,$isprint)!==false){

continue;

}

$isprint[]=$myprint;

if($classid&&$classid!=$gr['classid']){

continue;

}

if($mid&&$mid!=$gr['mid']){

continue;

}

if($gr['id']==$navinfor['id']&&$gr['classid']==$navinfor['classid']){

continue;

}

$tbname=$class_r[$gr['classid']]['tbname'];

if(!$tbname||InfoIsInTable($tbname)){

continue;

}

$r=$empire->fetch1("select * from {$dbtbpre}ecms_".$tbname." where id='$gr[id]' limit 1");

if(!$r['id']){

continue;

}

$str.=RepOtherTemp($temp_r[1],$r,$tr);

$i+=1;

if($i>=$num){

break;

}

}

}

$keyboardtext=$temp_r[0].$str.$temp_r[2];

if($str){

return $keyboardtext;

}else{

return '暂无相关信息';

}

}

二、 使用方法:

函数说明:user_OtherLink(调用条数,指定栏目id,指定模型id) ;

相关文章模板采用的是公共模板里的相关信息模板。

调用示例:

<?=user_OtherLink(10,0,1)?>

 

标签: 帝国cms 相关 调用 php

转载请注明出处:古典技术网

本页地址:https://www.gu90.com/chengxu/121.html

站住!留下神评!
相关文章
暂无相关信息