首页 > 网站开发 > V9二次开发 > phpcms_tag热门调用插件

V9二次开发

phpcms_tag热门调用插件

2020-04-02 12:23:24V9二次开发
首先将压缩包解压以后将phpcms文件夹放到根目录覆盖原来的文件夹然后打开phpcms model content_model class php 找到if(!$isimport && $
首先将压缩包解压以后将phpcms文件夹放到根目录覆盖原来的文件夹然后打开phpcms/model/content_model.class.php 找到if(!$isimport && $data['status']==99) {在他的上面添加如下代码
if($systeminfo['keywords']){
$this->db_tags = pc_base::load_model('tags_model'); 
//$this->db_tags_content = pc_base::load_model('tags_content_model');
$keywords = strpos($systeminfo['keywords'], ',') !== false ?  explode(',', $systeminfo['keywords']) : explode(' ', $systeminfo['keywords']);
$sql = '';
foreach($keywords as $key){
if($this->db_tags->get_one("`tag`='$key'", 'tagid')){
$this->db_tags->query("UPDATE `phpcms_tags` SET `usetimes`=usetimes+1 WHERE tag='$key'");
}else{
$this->db_tags->query("INSERT INTO `phpcms_tags`(`tag`,`usetimes`,`lastusetime`,`lasthittime`)VALUES('$key',1,".SYS_TIME.",".SYS_TIME.")");
}
$sql .= ",('$key','$urls[0]','$systeminfo[title]',$this->siteid,$modelid,$id,$systeminfo[catid],".SYS_TIME.")\n";
}
if($sql){
$sql = "INSERT INTO `phpcms_tags_content` (`tag`,`url`,`title`,`siteid`,`modelid`,`contentid`,`catid`,`updatetime`) VALUES ".substr($sql, 1);
$this->db_tags->query($sql);
}
}
 
找到$this->content_check_db->update($check_data,array('checkid'=>'c-'.$id.'-'.$this->modelid));
在他的下面添加如下代码
if($systeminfo['keywords']){
$this->db_tags = pc_base::load_model('tags_model'); 
$this->db_tags_content = pc_base::load_model('tags_content_model');
$keywords = strpos($systeminfo['keywords'], ',') !== false ? explode(',', $systeminfo['keywords']) : explode(' ', $systeminfo['keywords']);
$sql = '';
foreach($keywords as $key){
if(!$this->db_tags_content->get_one("`tag`='$key' AND `contentid` = $id AND `catid` =$systeminfo[catid] ", 'contentid')){
if($this->db_tags->get_one("`tag`='$key'", 'tagid')){
$this->db_tags->query("UPDATE `phpcms_tags` SET `usetimes`=usetimes+1 WHERE tag='$key'");
}else{
$this->db_tags->query("INSERT INTO `phpcms_tags`(`tag`,`usetimes`,`lastusetime`,`lasthittime`)VALUES('$key',1,".SYS_TIME.",".SYS_TIME.")");
}
$sql .= ",('$key','$urls[0]','$systeminfo[title]',$this->siteid,$this->modelid,$id,$systeminfo[catid],".SYS_TIME.")\n";
}
}
if($sql){
$sql = "INSERT INTO `phpcms_tags_content` (`tag`,`url`,`title`,`siteid`,`modelid`,`contentid`,`catid`,`updatetime`) VALUES ".substr($sql, 1);
$this->db_tags->query($sql);
}
}
// 添加到 tags 表结束
然后进入后台管理模块;可以看到TAG标签模块;点安装;再重建引索即可
最后再使用Get SQL语句就可以把热门标签调用出来了
{pc:get sql="SELECT tag,hits FROM v9_tags order by hits desc" num="8"} 

热门标签

{loop $data $r} 
{/loop}
{/pc}
索要附件请联系博主

文章评论

  • 加我请扫码

    工作时间

    周一至周日 9:00-18:00

  • 如果本站对你有帮助可以通过扫码支付打赏下哦!

    • 微信收款码
    • 支付宝收款码