帝国CMS模板内容页怎么用TAG调用相关文章

aaa

帝国cms模板内容页现用TAG调用相关文章的方法,一起来看看怎么操作吧:

  用tag调用相关文章的方法在帝国官方论坛上有人发过方法,但所使用的函数效率太低而且无法制定参数,不好用。现在使用的也是利用tag调用相关文章,非常好用。

  一、自定义函数

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//根据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) ;

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

  调用示例:

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

本文标题:帝国CMS模板内容页怎么用TAG调用相关文章

本文链接:https://www.kaifatu.com/article/147.html

相关文章

帝国cms如何调用栏目别名的方法

利用帝国CMS建站,有时需要在栏目页调用栏目别名这个字段。根据建站实践经验总结,我们在用帝国cms建站时经常会发现栏目的标题不好设置,栏目名称太长的话在后台那边看了眼花,太短…

Kaifatu 帝国cms教程
2021-06-29 170

帝国CMS列表页分页标题设置页码优化

通过修改/e/class/functions.php 文件来设置列表页标题序号。找到如下代码:$string=str_replace(&#39;[!--list.pageno--]&#39;,$pagenum,$string);修改为$string=str_replac…

Kaifatu 帝国cms教程
2023-03-05 411

帝国cms搜索模板制作教程详解(图文)

搜索模板搜索模板是指搜索结果页面使用的模板。(制作方法与列表模板相同)…

Kaifatu 帝国cms教程
2021-04-07 491

帝国cms如何禁止关键字替换alt和title中的关键词为链接

帝国cms如何禁止关键字替换alt和title中的关键词为链接…

Kaifatu 帝国cms教程
2021-04-07 494

帝国CMS终极栏目和非终极栏目的区别

栏目功能说明…

Kaifatu 帝国cms教程
2021-01-20 452
发表评论
暂无评论