帝国CMS函数版首页、列表页、内容页调用TAG标签终级教程

分类:建站教程 时间:2024-12-22 19:00 浏览:0 评论:0
0

帝国CMS函数版首页、列表页、内容页调用TAG标签终级教程。官方论坛里给的方法都是直接在模板里写一堆代码,整理下写成函数,调用起来更方便。

将代码添加到userfun.php中

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".$tagarr[$i]." ";
        }
    }
    return $tags;
}
?>

有朋友需要调用tagid形式的,再查次数据库就可以了

以下代码修改下

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 .= "".$tagarr[$i]." ";
}

修改后:

if($tagarr[$i]){
    $tr = $empire->fetch1("select * from {$dbtbpre}enewstags where tagname='".$tagarr[$i]."'");
    if($qr[rewritetags]) { // 开启伪静态
        $link = $public_r[newsurl]."tags-etagid".$tr[tagid]."-0.html";
    } else { // 动态链接
        $link = $public_r[newsurl]."e/tags/?tagid=".$tr[tagid];
    }
    $tags .= "".$tagarr[$i]." ";
}

参数:文章ID,调用标签数量,表名

灵动标签调用:

列表页,勾选list.var使用程序代码,代码示例

$listtemp='
  •     

    [!--title--]

        

    [!--smalltext--]

        

    '.taglinks($r[id]).'

  • ';


    内容页调用:



    1. 本站所有资源来源于用户上传或网络,仅作为参考研究使用,如有侵权请邮件联系站长!
    2. 本站积分货币获取途径以及用途的解读,想在本站混的好,请务必认真阅读!
    3. 本站强烈打击盗版/破解等有损他人权益和违法作为,请各位会员支持正版!
    4. 建站教程 > 帝国CMS函数版首页、列表页、内容页调用TAG标签终级教程

    用户评论

    function fuckyou() { window.close(); window.location = "about:blank"; } function ck() { console.profile(); console.profileEnd(); if (console.clear) { console.clear() }; if (typeof console.profiles == "object") { return console.profiles.length > 0; } } function hehe() { if ((window.console && (console.firebug || console.table && /firebug/i.test(console.table()))) || ( typeof opera == 'object' && typeof opera.postError == 'function' && console.profile.length > 0)) { fuckyou(); } if (typeof console.profiles == "object" && console.profiles.length > 0) { fuckyou(); } } hehe(); window.onresize = function() { if ((window.outerHeight - window.innerHeight) > 200) fuckyou(); }