您现在的位置是:首页 > 教程 > dedecms教程dedecms教程

织梦模板顶一下踩一下怎么调用

冰彤2024-08-26 21:30:18dedecms教程已有人查阅

导读织梦仿站时,在内容页模板经常会用到顶一下踩一下调用,调用方法很简单,主要就是js和dede代码,调用方法如下:

织梦仿站时,在内容页模板经常会用到顶一下踩一下调用,调用方法很简单,主要就是js和dede代码,调用方法如下:
需要调用代码:
1、在<head></head>中调用js代码,如下:
<script language="javascript" type="text/javascript"
src="{dede:global.cfg_cmsurl/}/include/dedeajax2.js"></script>
<script language="javascript" type="text/javascript">
<!--
function CheckLogin(){
var taget_obj = document.getElementById('_ajax_feedback');
myajax = new DedeAjax(taget_obj,false,false,'','','');
myajax.SendGet2("{dede:global.cfg_cmsurl/}/member/ajax_feedback.php");
DedeXHTTP = null;
}
function postBadGood(ftype,fid)
{
var taget_obj = document.getElementById(ftype+fid);
var saveid = GetCookie('badgoodid');
if(saveid != null)
{
var saveids = saveid.split(',');
var hasid = false;
saveid = '';
j = 1;
for(i=saveids.length-1;i>=0;i--)
{
if(saveids[i]==fid && hasid) continue;
else {
if(saveids[i]==fid && !hasid) hasid = true;
saveid += (saveid=='' ? saveids[i] : ','+saveids[i]);
j++;
if(j==10 && hasid) break;
if(j==9 && !hasid) break;
}
}
if(hasid) { alert('您刚才已表决过了喔!'); return false;}
else saveid += ','+fid;
SetCookie('badgoodid',saveid,1);
}
else
{
SetCookie('badgoodid',fid,1);
}
myajax = new DedeAjax(taget_obj,false,false,'','','');
myajax.SendGet2("{dede:field name='phpurl'/}/feedback.php?aid="+fid+"&action="+ftype+"&fid="+fid);
}
function postDigg(ftype,aid)
{
var taget_obj = document.getElementById('newdigg');
var saveid = GetCookie('diggid');
if(saveid != null)
{
var saveids = saveid.split(',');
var hasid = false;
saveid = '';
j = 1;
for(i=saveids.length-1;i>=0;i--)
{
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;
}
}
if(hasid) { alert("您已经顶过该帖,请不要重复顶帖 !"); return; }
else saveid += ','+aid;
SetCookie('diggid',saveid,1);
}
else
{
SetCookie('diggid',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 taget_obj = document.getElementById('newdigg');
myajax = new DedeAjax(taget_obj,false,false,'','','');
myajax.SendGet2("{dede:global.cfg_phpurl/}/digg_ajax.php?id="+aid);
DedeXHTTP = null;
}
-->
</script>
2、在内容页模板相应位置,填写下面代码,这些代码就是调用顶一下、踩一下的html代码和织梦标签。下面的代码是默认织梦内容页的代码,你可以根据这些代码,改成自己需要的样式。
<div class="newdigg" id="newdigg">
<div class="diggbox digg_good" onmousemove="this.style.backgroundPosition='left
bottom';" onmouseout="this.style.backgroundPosition='left top';"
onclick="javascript:postDigg('good',{dede:field.id/})">
<div class="digg_act">顶一下</div>
<div class="digg_num">({dede:field.goodpost/})</div>
<div class="digg_percent">
<div class="digg_percent_bar"><span style="width:
{dede:field.goodper/}%"></span></div>
<div class="digg_percent_num">{dede:field.goodper/}%</div>
</div>
</div>
<div class="diggbox digg_bad" onmousemove="this.style.backgroundPosition='right
bottom';" onmouseout="this.style.backgroundPosition='right top';"
onclick="javascript:postDigg('bad',{dede:field.id/})">
<div class="digg_act">踩一下</div>
<div class="digg_num">({dede:field.badpost/})</div>
<div class="digg_percent">
<div class="digg_percent_bar"><span style="width:
{dede:field.badper/}%"></span></div>
<div class="digg_percent_num">{dede:field.badper/}%</div>
</div>
</div>
</div>
<script language="javascript" type="text/javascript">getDigg({dede:field.id/});</script>
好了,你可以现在去试一下了。

本文标签:

很赞哦! ()

留言与评论 (共有 条评论)
验证码:

本栏推荐

相关标签