帝国CMS首页、列表页、内容页调用TAG标签方法

  • 自定义函数:

    function taglinks($aid, $num=5, $tbname='news') {
        global $public_r, $dbtbpre, $empire, $navinfor, $class_r;
        $qr = $empire->fetch1("select rewritetags from {$dbtbpre}enewspublic limit 1");
        $sr = $empire->fetch1("select stb from {$dbtbpre}ecms_{$tbname} where id=$aid");
        $fr = $empire->fetch1("select infotags from {$dbtbpre}ecms_{$tbname}_data_{$sr[stb]} where id=$aid");
        $tagstr = '' . $fr[infotags] . '';
        $tagarr = explode(",", $tagstr);
        for ($i = 0; $i < count($tagarr) && $i < $num; $i++) {
            if ($tagarr[$i]) {
                if ($qr[rewritetags]) { // 开启伪静态
                    $link = $public_r[newsurl] . "tags-" . urlencode($tagarr[$i]) . "-0.html";
                } else { // 动态链接
                    $link = $public_r[newsurl] . "e/tags/?tagname=" . urlencode($tagarr[$i]);
                }
                $tags .= "<a href='$link' target='_blank'>" . $tagarr[$i] . "</a> ";
            }
        }
        return $tags;
    }
  • 调用方法:

    • 首页和内容页:
      <!--?=taglinks($navinfor[id])?-->
    • 列表页:
      $listtemp = '<ul><li><h3><a href="[!--titleurl--]">[!--title--]</a></h3>[!--smalltext--]' . taglinks($r[id]) . '</li></ul>';

 

posted @   黄文Rex  阅读(101)  评论(0编辑  收藏  举报
(评论功能已被禁用)
相关博文:
阅读排行:
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 上周热点回顾(2.17-2.23)
点击右上角即可分享
微信分享提示