(还存在一个问题:当点击支持以后,支持数量会变化,但是一刷新页面又会变回原来的数字,当dedecms后台更新页面缓存以后该处数量显示点击支持后的数量)
模板文件:list_article.htm 注意红色标注位置:
<link href="{dede:global.cfg_templets_skin/}/style/dedecms.css" rel="stylesheet" media="screen" type="text/css" />
<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 diggItem = "newdigg_" + aid;
var taget_obj = document.getElementById(diggItem);
var diggidItem = "diggid_" + aid;
var saveid = GetCookie(diggidItem);
if(saveid != null)
{
var saveids = saveid.split(',');
var hasid = false;
saveid = '';
j = 1;
for(i=saveids.length-1;i>=0;i--)
{
if(saveids==aid && hasid) continue;
else {
if(saveids==aid && !hasid) hasid = true;
saveid += (saveid=='' ? saveids : ','+saveids);
j++;
if(j==20 && hasid) break;
if(j==19 && !hasid) break;
}
}
if(hasid) { alert("您已经顶过该帖,请不要重复顶帖 !"); return; }
else saveid += ','+aid;
SetCookie(diggidItem,saveid,1);
}
else
{
SetCookie(diggidItem,aid,1);
}
myajax = new DedeAjax(taget_obj,false,false,'','','');
var url = "{dede:global.cfg_phpurl/}/digg_ajax.php?action="+ftype+"&id="+aid;
myajax.SendGet2(url);
}
function getDigg(aid)
{
var diggItem = "newdigg_" + aid;
var taget_obj = document.getElementById(diggItem);
myajax = new DedeAjax(taget_obj,false,false,'','','');
myajax.SendGet2("{dede:global.cfg_phpurl/}/digg_ajax.php?id="+aid);
DedeXHTTP = null;
}
-->
</script>
{dede:list pagesize='10'}
<li> [field:array runphp='yes']@me = (empty(@me['litpic']) ? "" : "<a [email]href='{@me['arcurl']}'[/email] class='preview'><img [email=src='{@me['litpic']}'/></a]src='{@me['litpic']}'/></a[/email]>"); [/field:array]
[<b>[field:typelink/]</b>] <a href="[field:arcurl/]" class="title">[field:title/]</a> <span class="info"> <small>日期:</small>[field:pubdate function="GetDateTimeMK(@me)"/] <small>点击:</small>[field:click/] <small>好评:</small>[field:scores/] </span>
<p class="intro"> [field:description/]... </p>
<!--开始顶-->
<div class="viewbox">
<div class="newdigg" id="newdigg_[field:id/]">
<div onclick="javascript:postDigg('good',[field:id/])">
<div class="blue12" style="cursor:hand;">投票 ([field:goodpost/])票</div>
</div>
<!--结束顶-->
</li>
{/dede:list}
具体的 顶样式 要去 plus/digg_ajax.php 里面自己修改一下就可以了
位置:
$digg = '<div class="jpsg_zc" id="newdiggs_'.$id.'" onclick="javascript:postDigg(\'good\','.$id.')">
<a ><img src="/templets/ver1/images/zc.jpg" /></a><strong>'.$row['goodpost'].'</strong>
</div>';
如图样式:
//模板文件:list_article.htm 注意红色标注部分
<link href="{dede:global.cfg_templets_skin/}/style/dedecms.css" rel="stylesheet" media="screen" type="text/css" /> <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 diggItem = "newdigg_" + aid; var taget_obj = document.getElementById(diggItem); var diggidItem = "diggid_" + aid; var saveid = GetCookie(diggidItem); if(saveid != null) { var saveids = saveid.split(','); var hasid = false; saveid = ''; j = 1; for(i=saveids.length-1;i>=0;i--) { if(saveids==aid && hasid) continue; else { if(saveids==aid && !hasid) hasid = true; saveid += (saveid=='' ? saveids : ','+saveids); j++; if(j==20 && hasid) break; if(j==19 && !hasid) break; } } if(hasid) { alert("您已经顶过该帖,请不要重复顶帖 !"); return; } else saveid += ','+aid; SetCookie(diggidItem,saveid,1); } else { SetCookie(diggidItem,aid,1); } myajax = new DedeAjax(taget_obj,false,false,'','',''); var url = "{dede:global.cfg_phpurl/}/digg_ajax.php?action="+ftype+"&id="+aid; myajax.SendGet2(url); } function getDigg(aid) { var diggItem = "newdigg_" + aid; var taget_obj = document.getElementById(diggItem); myajax = new DedeAjax(taget_obj,false,false,'','',''); myajax.SendGet2("{dede:global.cfg_phpurl/}/digg_ajax.php?id="+aid); DedeXHTTP = null; } --> </script> {dede:list pagesize='10'} <li> [field:array runphp='yes']@me = (empty(@me['litpic']) ? "" : "<a [email]href='{@me['arcurl']}'[/email] class='preview'><img [email=src='{@me['litpic']}'/></a]src='{@me['litpic']}'/></a[/email]>"); [/field:array] [<b>[field:typelink/]</b>] <a href="[field:arcurl/]" class="title">[field:title/]</a> <span class="info"> <small>日期:</small>[field:pubdate function="GetDateTimeMK(@me)"/] <small>点击:</small>[field:click/] <small>好评:</small>[field:scores/] </span> <p class="intro"> [field:description/]... </p> <!--开始顶--> <div class="viewbox"> <div class="newdigg" id="newdigg_[field:id/]"> <div onclick="javascript:postDigg('good',[field:id/])"> <div class="blue12" style="cursor:hand;">投票 ([field:goodpost/])票</div> </div> <!--结束顶--> </li> {/dede:list} //具体的 顶样式 要去 plus/digg_ajax.php 里面自己修改一下就可以了
//修改位置:
$digg = '<div class="jpsg_zc" id="newdiggs_'.$id.'" onclick="javascript:postDigg(\'good\','.$id.')"> <a ><img src="/templets/ver1/images/zc.jpg" /></a><strong>'.$row['goodpost'].'</strong> </div>';
参考地址:在某论坛看到的 具体地址忘记了