织梦列表页,支持顶(赞)和踩的功能,顶过后标红高亮显示

站长新闻 11-09 浏览 242

模板

01
1 {dede:arclist row='6' orderby='id' titlelen='100'} 2   3         [field:goodpost/] 4   5 {/dede:arclist}

css

1 .icon-heart2{ 2     background: url(../images/bg-main.png) -22px 5px no-repeat; 3 } 4 .icon-heart2:hover{ 5     background: url(../images/bg-main.png) 2px 4px no-repeat; 6 } 7 .icon-heart-on{ 8     background: url(../images/bg-main.png) 2px 4px no-repeat; 9 }

然后在,plus中新建立一个digg_ajax_list.PHP文件,内容为
 

01 ExecuteNoneQuery("Update `$maintable` set scores = scores + {$cfg_caicai_add},goodpost=goodpost+1,lastpost=".time()." where id='$id'");   16 }   17 else if($action=='bad')   18 {   19     $dsql->ExecuteNoneQuery("Update `$maintable` set scores = scores - {$cfg_caicai_sub},badpost=badpost+1,lastpost=".time()." where id='$id'");   20 }   21 $digg = '';   22 $row = $dsql->GetOne("Select goodpost,badpost,scores From `$maintable` where id='$id' ");   23 if(!is_array($row))   24 {   25     exit();   26 }   27 if($row['goodpost']+$row['badpost'] == 0)   28 {   29     $row['goodper'] = $row['badper'] = 0;   30 }   31 else 32 {   33     $row['goodper'] = number_format($row['goodpost']/($row['goodpost']+$row['badpost']),3)*100;   34     $row['badper'] = 100-$row['goodper'];   35 }   36    37 if(empty($formurl)) $formurl = '';   38 if($formurl=='caicai')   39 {  40     if($action == 'good') $digg = $row['goodpost'];   41     if($action == 'bad') $digg  = $row['badpost'];   42 }   43 else 44 {   45     $row['goodper'] = trim(sprintf("%4.2f", $row['goodper']));   46     $row['badper'] = trim(sprintf("%4.2f", $row['badper']));       47     $digg = '      '.$row['goodpost'];   //点击后,如果从没有被赞过,则自动把新的点击次数重写入目标位置. 48 }   49 AjaxHead();   50 echo $digg;   51 exit();   52 ?>
标签:
本文版权声明本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,请联系本站客服,一经查实,本站将立刻删除。

热门推荐