1、首页,列表页和文章页调用所的tag标签
{dede:tag row='8' getall='1' sort='month'}
支持属性
row|30 行数
sort|new 排序
getall|0 调用类型
可以查看/include/taglib/tag.lib.php
2、列表页调用每一篇文章的tag标签
[field:id runphp=yes]
$tsql = new DedeSql(false);
$tags = '';
$tsql->SetQuery("Select i.tag From ying_taglist t left join ying_tagindex i on i.id=t.tid where t.aid='@me'");
$tsql->Execute('t');
while($row = $tsql->GetArray('t',MYSQL_ASSOC)){
$tags .= "<a href='/tags.php?/".urlencode($row['tag'])."'>".$row['tag']."</a>";
}
@me=$tags;
[/field:id]
|
3、文章页调用该篇正文的tag标签
{dede:field.tags/}
默认的TAG是无链接的,如果你希望该tag带上链接,则打开include/common.func.php ,大约755行,找到
//获得某文档的所有tag
function GetTags($aid)
{
global $dsql;
$tags = '';
$query = "Select tag From `ying_taglist` where aid='$aid' ";
$dsql->Execute('tag',$query);
while($row = $dsql->GetArray('tag'))
{
$tags .= ($tags=='' ? $row['tag'] : ','.$row['tag']);
}
return $tags;
}
|
修改为
//获得某文档的所有tag
function GetTags($aid)
{
global $dsql;
$tags = '';
$query = "Select tag From `dede_taglist` where aid='$aid' ";
$dsql->Execute('tag',$query);
while($row = $dsql->GetArray('tag'))
{
$tags.= ($tags=='' ? "<a href=/tags.php?/{$row['tag']} target=_blank>{$row['tag']}</a>" : ','."<a href=/tags.php?/{$row['tag']} target=_blank>{$row['tag']}</a>");
}
return $tags;
}
|