DedeCms仿Digg插件的首页、列表页调用投票改动
称号:仿Digg 我顶! DEDE插件
目标:扭转文章投票模式,页面更美观
针对版本:DEDE3.1 DEDE 4.X
阐明:
其实这个插件很简略,只是把投票模式改了一种示意方法,然而效果很好,需求的冤家可能往下看装置方法。
原理:同投票。
装置方法:
1、archives 数据表新增 vote (投票统计,与原来投票系统来到),并创建投票统计表,新增vote字段
ALTER TABLE `dede_archives` ADD `vote` INT DEFAULT '0' NOT NULL ;
创建统计表
以下为引用的内容: CREATE TABLE `dede_review` (
`id` int(11) NOT NULL auto_increment,
`str_ip` varchar(32) NOT NULL,
`num_arc` int(11) NOT NULL,
`date_review` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `str_ip` (`str_ip`,`num_arc`)
) ENGINE=MyISAM DEFAULT CHARSET=gb2312 AUTO_INCREMENT=66 ;
2、把附件中的JS目录放置到对应模板目录下,并在模板页面中调用
<script language=javascript src="/templets/你的模板目录/js/prototype.js"></script>
<script language=javascript src="/templets/你的模板目录/js/moo.fx.js"></script>
3、模板页面减少JS
以下为引用的内容: function wo_ding(num_id)
{
url = "/plus/wo_ding.php?aid="+num_id+"&post=vote&m=" + Math.random();
new ajax(url, {method: 'get', onComplete:return_review});
}
function return_review(ajax)
{
str_error_num = ajax.responseText
if(str_error_num==0)
{
alert("操作失误,或许用户反复评分,这次评分无效...");
}
else
{
alert("感激您的投票,谢谢...^_^")
$("s_ding").innerHTML = str_error_num;
}
}
4、模板页面减少 我顶! 层标签
以下为引用的内容:
<div id="ding">
<p class="vote_show"><a href="javascript:wo_ding({dede:field/});" title="给我顶到首页引荐!"><span id="s_ding"><script src="{dede:field/}/wo_ding.php?aid={dede:field/}&post=show" language="javascript"></script></span></a></p>
<p class="vote_action"><a href="javascript:wo_ding({dede:field/});" title="给我顶到首页引荐!">我顶!</a></p>
</div>
5、减少CSS,能够需求本人微调
以下为引用的内容: #ding
{
text-align:center;
margin:0 0 0 20px;
width:54px;
height:71px;
background:url(../images/vote.png) no-repeat;
}
#ding a
{
color:#333;
text-decoration:none;
}
#ding .vote_show
{
margin:10px 0 0 0;
font-size:25px;
font-weight:bold;
line-height:30px;
}
#ding .vote_action
{
margin:15px 0 0 0;
}
6、修正外围获取列表文件 include/inc/inc_fun_SpGetArcList.php
留意:假设你不太了解PHP记得在更新的中央打上记号。
第 65 行:
else if($orderby=='rand') $ordersql = " order by rand()";
修正为:
else if($orderby=='vote') $ordersql = " order by arc.vote $orderWay";
else if($orderby=='rand') $ordersql = " order by rand()";
DEDE 3.1 改动第 130 行
DEDE 4.x 改动第 152 行
就加了个“投票”字段的查询
arc.money,arc.litpic,arc.writer,arc.shorttitle,arc.memberid,
修正为:
arc.money,arc.litpic,arc.writer,arc.shorttitle,arc.memberid,arc.vote,
7、把附件中的PHP目录下的文件放置到plus目录下
8、images目录下的文件放到 你的模板目录 下的 images 目录下
9、装置实现,首页调用方法
以下为引用的内容:
{dede:arclist row=10 titlelen=24 orderby=vote}
·[field:textlink/]([field:vote/])<br/>
{/dede:arclist}
以下是首页或列表页调用投票性能的改动
JS局部:
以下为引用的内容: function wo_ding(num_id)
{
url = "/plus/wo_ding.php?aid="+num_id+"&post=vote&m=" + Math.random();
new ajax(url, {method: 'get', onComplete:return_review});
}
function return_review(ajax)
{
str_error_num = ajax.responseText
if(str_error_num==0)
{
alert("操作失误,或许用户反复评分,这次评分无效...");
}
else
{
alert("感激您的投票,请持续阅读^_^")
location.reload()
}
}
模板标签局部:
以下为引用的内容:
<div id="ding">
<p class="vote_show"><a href="javascript:wo_ding([field:ID/]);" title="我顶!"><span id="s_ding">[field:vote/]</span></a></p>
<p class="vote_action"><a href="javascript:wo_ding([field:ID/]);" title="我顶!">我顶!</a></p>
</div>