帝国CMS tags 页列表页内容页调用函数版代码

  1. 添加函数

    • 在 /e/class/userfun.php 文件中添加以下代码:
    function tagslink($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 { // 动态的tags链接                 $link = $public_r[newsurl] . "e/tags/?tagname=" . urlencode($tagarr[$i]);             }             $tags .= "<a href='$link' target='_blank'>" . $tagarr[$i] . "</a> ";         }     }     return $tags; }
  2. 调用方法

    • 首页、列表页:
       
       
      <?=tagslink($bqr[id])?>
    • 内容页:
       
       
      <?=tagslink($navinfor[id])?>
wx.jpg ywfw.jpg
热门