一聚教程网:一个值得你收藏的教程网站

热门教程

织梦系统中文章自动插入关键字和相关链接实现方法

时间:2022-06-25 16:36:48 编辑:袖梨 来源:一聚教程网

 代码如下 复制代码

//关键字和相关文章插入开始
    $open_mytag=1;//1为开启,0为关闭
    if($open_mytag){
        if($keywords){
            $mykeyword = explode(',',$keywords);
            $body = SpLongBody($body,700,$mykeyword[0]);//每隔200字节插入关键字1(200可改)
            $body = count($mykeyword)>1?SpLongBody($body,1200,$mykeyword[1]):$body;//插入关键字2
        }//关键字插入
        if($tags){
            $mytag = explode(',',$tags);
            $aa=rand(0,count($mytag)-1);
            $stag=$mytag[$aa];
            $mylink = $dsql->GetOne("Select aid From  `#@__taglist` where tag='$stag' order by rand()");
            $myid = $mylink['aid'];
            $mytitle = $dsql->GetOne("Select title From  `#@__archives` where id='$myid'");
            $myurl = MakeArt($myid,true,true,$isremote);
            $myst = $mytitle['title'];
            $mys = '<a href="'.$myurl.'">'.$myst.'</a>';
            $mynum = ceil(strlen($body)/2);
            $body = SpLongBody($body,$mynum,$mys);//插入相关链接
        }//相关文章插入
    }

//关键字和相关文章插入结束

热门栏目