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