注册 登录 欢迎您到模板精:织梦模板_dede模板_免费网站模板_网站源码下载

织梦教程_免费织梦模板下载_dede模板

该栏目分享织梦建站的基础知识,从织梦CMS的安装,到织梦标签的常规调用,以及织梦的常见问题答疑都有涉及。

当前位置:首页 > 织梦教程 >

DEDE保存TAGS标签之InsertTags函数

免费网站模板 2020-09-15 10:34 织梦教程 评论
/**
 *  插入Tags
 *
 * @access    public
 * @param     string  $tag  tag标签
 * @param     int  $aid  文档AID
 * @return    void
 */
if ( ! function_exists('InsertTags'))
{
    function InsertTags($tag, $aid)
    {
        $tags = explode(',',$tag);
        foreach($tags as $tag)
        {
            $tag = trim($tag);
            if(isset($tag[20]) || $tag!=stripslashes($tag))
            {
                continue;
            }
            InsertOneTag($tag,$aid);
        }
    }
}
 
通过如下函数获取保存在表里的TAGS标签:
 
 
 
/**
 *  获得某文档的所有tag
 *
 * @param     int     $aid  文档id
 * @return    string
 */
if ( ! function_exists('GetTags'))
{
    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=='' ? $row['tag'] : ','.$row['tag']);
        }
        return $tags;
    }
}
 
函数在/include/helpers/archive.helper.php中