只有第0点试成功过!!其余未试
0.
include/helpers/archive.helper.php
增加方法:
function GetTags_list($aid)
{
global $dsql;
$tags = '';
$query = "SELECT tag FROM `taglist` WHERE aid='$aid' ";
$dsql->Execute('tag',$query);
while($row = $dsql->GetArray('tag'))
{
$tags .= ($tags=='' ? "<a href='/tags.php?/".urlencode($row['tag'])."'>".$row['tag']."</a>" : ','."<a href='/tags.php?/".urlencode($row['tag'])."'>".$row['tag']."</a>");
}
return $tags;
}
调用:
[field:id function=GetTags_list(@me)/]
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 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]
3,文章页调用该篇正文的tag
{dede:field.tags/}
默认的TAG是无链接的,如果你希望该tag带上链接,则打开include/common.func.php ,大约755行,找到
//获得某文档的所有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;
}