DEDE的顶客如何实现文章被顶后首页实时刷,而不需要全站刷新?就像A5首页的那样。
{dede:arclist row='5' titlelen='20'}
<script language="javascript" type="text/javascript">getDigg([field:id/]);</script>
这里的<script language="javascript" type="text/javascript">getDigg([field:id/]);</script> 被加在了arclist标签里作为底层模板,是为了让每一篇文档都可以独立显示其顶和踩的状态。
<script language="javascript" type="text/javascript" src="{dede:global.cfg_cmsurl/}/include/dedeajax2.js"></script>
<script language="javascript" type="text/javascript">
function postDigg(ftype,aid)
var taget_obj = document.getElementById('diggNum'+aid);
var saveidsaveids = saveid.split(',');
var hasid = false;
if(saveids[i]==aid && hasid) continue;
else {
if(saveids[i]==aid && !hasid) hasid = true;
saveid += (saveid=='' ? saveids[i] : ','+saveids[i]);
j++;
if(j==20 && hasid) break;
if(j==19 && !hasid) break;
SetCookie('diggid',saveid,1);
else
SetCookie('diggid',aid,1);
var url = "{dede:global.cfg_phpurl/}/digg_ajax_index.php?action="+ftype+"id="+aid;
myajax.SendGet2(url);
require_once(dirname(__FILE__)."/../include/common.inc.php");
$action = isset($action) ? trim($action) : '';
if($id < 1)
$maintable = 'dede_archives';
if($action == 'good')
$dsql->ExecuteNoneQuery("Update `$maintable` set scores = scores + {$cfg_caicai_add},goodpost=goodpost+1,lastpost=".time()." where id='$id'");
else if($action=='bad')
$dsql->ExecuteNoneQuery("Update `$maintable` set scores = scores - {$cfg_caicai_sub},badpost=badpost+1,lastpost=".time()." where id='$id'");
exit();
if($row['goodpost']+$row['badpost'] == 0)
$row['goodper'] = $row['badper'] = 0;
$row['goodper'] = number_format($row['goodpost']/($row['goodpost']+$row['badpost']),3)*100;
$row['badper'] = 100-$row['goodper'];
if(emptyempty($formurl)) $formurl = '';
if($formurl=='caicai')
if($action == 'good') $digg = $row['goodpost'];
if($action == 'bad') $digg = $row['badpost'];
$row['goodper'] = trim(sprintf("%4.2f", $row['goodper']));
$row['badper'] = trim(sprintf("%4.2f", $row['badper']));