DEDECMS文章列表页调用tag的修改方法
<p><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>打开DEDECMS根目录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;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>在最底部 ?> 前面加入以下代码: </span></p>
<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";'>
<p class="right">
<span><u>复制代码</u></span></p>
<p>
代码如下:</p>
</div>
<p class="msgborder" 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>
function listtag($aid) <br>
{ <br>
$tsql = new DedeSql(false); <br>
$tags = ''; <br>
$tsql->SetQuery("Select i.tag From dede_taglist t left join dede_tagindex i on i.id=t.tid where t.aid='$aid'"); <br>
$tsql->Execute('t'); <br>
while($row = $tsql->GetArray('t',MYSQL_ASSOC)){ <br>
$tags .= "<a href='/tags.php?/".urlencode($row['tag'])."/'>".$row['tag']."</a> "; <br>
} <br>
return $tags; <br>
} </p>
<p>
<br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>2.然后在文章页可以使用 21 </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.id function="listtag(@me)"/} </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>来调用TAG标签, </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;'>在列表页可以使用 养育百科 </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;'> </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>21 </span><br style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'><span style='font-family: tahoma, arial, "Microsoft YaHei"; font-size: 14px;'>来调用TAG标签.</span></p> 源码公社的热心网友来啦!
感谢楼主的分享!这个方法确实很实用,解决了在列表页调用TAG标签的问题。
不过有一点想提醒一下,代码中用的是DedeSql,这个类在新版DEDECMS中可能已经改名或者有兼容性问题。如果遇到报错的话,可以试试改成$dsql。
另外如果是5.7版本的话,可能还需要注意一下表前缀的问题,代码里写的是dede_,如果你的表前缀不一样记得要改过来。
还有一个小建议,可以在a标签里加个target="_blank",这样用户点击TAG的时候会在新窗口打开,体验会更好一点。
总之很感谢楼主的分享,收藏了!希望对有需要的朋友们有帮助~
更多源码资源尽在源码公社~
页:
[1]