用tag调用相关文章的方法在帝国官方论坛上有人发过方法,但所使用的函数效率太低而且无法制定参数,不好用。东坡网现在使用的也是利用tag调用相关文章,非常好用。
一、自定义函数
自定义函数user_OtherLink ,将此函数放入 eclassuserfun.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会员空间新闻列表图片列表按栏目查看
- 下一篇: 帝国cms验证码打叉不显示解决方法
- 最新文章
-
- phpcms v9无法更新url
- phpcms注册会员操作失败
- phpcms怎么修改模板
- phpcms添加内容报500错误的原因及解决方法
- linux服务器下phpcms提示hash数据验证失败的解决方法
- phpcms与phpsso通信失败的解决方法
- phpcms上传图片提示服务器安全认证错误的原因及解决方法
- phpcms v9更新栏目缓存失败的原因及解决方法
- phpcms v9后台登录提示验证码错误
- phpcms可以做什么?
- phpcms v9安装失败
- phpcms会员登录失败
- phpcms前台js获取不到cookie用户信息
- phpcms控制器不存在
- phpcms v9 php7可以运行吗
- phpcms js乱码怎么解决
- phpcms提示服务器安全认证错误
- phpcms php.ini在哪里
- phpcms phpsso验证码错误
- phpcms v9参数传递错误
- 热门文章
- 热门tag
- 随机tag