陶声依然 發表於 2023-10-15 00:00:00

织梦DEDECMS网站栏目页获取当前顶级栏目名称的标签

<span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>下面拓展出一个方法来实现这个效果、: </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>在include/common.func.php的最下方加入: </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><div class="msgheader" style='margin: 3px auto 0px; padding: 0px 3px; outline: none; line-height: 21.6px; clear: both; border-width: 1px; border-style: solid; border-color: rgb(0, 153, 204); background: rgb(246, 251, 255); overflow: hidden; font-family: tahoma, arial, "Microsoft YaHei";'>
        <div class="right">
                <span><u>复制代码</u></span>
</div>
        代码如下:</div>
<div class="msgborder" id="phpcode1" style='margin: 0px auto 3px; padding: 0px 3px; outline: none; line-height: 25.2px; font-size: 14px; clear: both; border-right: 1px solid rgb(0, 153, 204); background: rgb(221, 237, 251); overflow: hidden; border-left: 1px solid rgb(0, 153, 204); word-break: break-all; border-bottom: 1px solid rgb(0, 153, 204); word-wrap: break-word; font-family: tahoma, arial, "Microsoft YaHei";'>
        <br>
        //获取顶级栏目名 <br>
        function GetTopTypename($id) <br>
        { <br>
        global $dsql; <br>
        $row = $dsql-&gt;GetOne("SELECT typename,topid FROM jiemou_arctype WHERE id= $id"); <br>
        if ($row['topid'] == '0') <br>
        { <br>
        return $row['typename']; <br>
        } <br>
        else <br>
        { <br>
        $row1 = $dsql-&gt;GetOne("SELECT typename FROM jiemou_arctype WHERE id= $row"); <br>
        return $row1['typename']; <br>
        } <br>
        } </div>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>在文章页或者栏目列表页调用时,在所要调用栏目名称的位置加上下面这行代码即可实现: </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>{dede:field name='typeid' function="GetTopTypename(@me)" /} </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>这个在我们做很多dedecms网站的时候都会用到,记住吧!</span>
頁: [1]
查看完整版本: 织梦DEDECMS网站栏目页获取当前顶级栏目名称的标签