dede程序5.7列表頁(yè)調(diào)用tag標(biāo)簽
時(shí)間: 2018-12-12 08:24
閱讀: 次
作者:素材無憂網(wǎng)
只有第0點(diǎn)試成功過??!其余未試
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;
}
調(diào)用:
[field:id function=GetTags_list(@me)/]
1,首頁(yè),列表頁(yè)和文章頁(yè)調(diào)用所,的tag
{dede:tag row='8' getall='1' sort='month'}
支持屬性
row|30 行數(shù)
sort|new 排序
getall|0 調(diào)用類型
可以查看/include/taglib/tag.lib.php
2,列表頁(yè)調(diào)用每一篇文章的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,文章頁(yè)調(diào)用該篇正文的tag
{dede:field.tags/}
默認(rèn)的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;
}
標(biāo)簽: