Mar 19, 2007
本文永久地址:
http://blog.znsunimage.com/plugins-list/ajax-comments-reply/
MSN留言风格的Ajax Commens-Reply插件
(MSN Type Ajax Comments-Reply Plugin)
- 点击下载,版本:1.0β ,最近更新于2007/03/18
原创于懶懶喵日記,后Zhang-Zi根据此版本制作了非常优秀的Ajax Comments-Reply插件,现在这个版本实质是将Zhang-Zi的两个版本(一个是以前的实现msn风格的留言版本,另一个是他现在用的版本)合二为一。因此,这里特别感谢两位作者之前所作的大量努力。此版本主要实现的功能如下:
- 可以直接在各种页面上(主页,多文章页面,单篇文章)回复留言(默认为5层嵌套),使得讨论更有针对性。
此修订版主要改了一下几个方面:
- 修改了原插件必须放置在wordpress根目录下的缺点,同时保留了prototype.lite等函数(因为我用的litebox中也用到了prototype.lite【注】litebox是lightbox的精简版本,用以实现图片显示的特殊效果)。
- 整合了Zhang-Zi的两个不同版本的插件,合并了部分代码,使之达到现在的显示效果。
- 修改了留言栏的式样,使得符合我的blog风格。
- 压缩了javascript代码,其中css文件没有压缩,如果有需要,可以参考我的文章:加速Wordpress
压缩包内容,包含在一个comment-reply的文件夹:
- readme.html //Read Me
- ajax-comments.php //实现在多文章页面上留言
- comments.php //实现单页面上的留言
- comment.css // css文件,控制评论栏效果
- comment.js, parse.js.php //已压缩的 javascript文件
- moo.ajax.js, prototype.lite.js, moo.fx.js //prototype.lite 模块
- comments-ajax.php //ajax留言处理
- comment-reply.php //插件控制
- working.gif //Loading留言时候的动态图标
- unzip文件夹 //未压缩过的javascript版本
插件安装使用:
- 从上面链接下载安装文件,解压缩后得到一个comment-reply文件夹
- 把文件夹的comments.php放到模版目录下,覆盖同名文件—请备份旧的comments.php
- 将comment-reply文件夹整个放入插件目录。结构如下:
---------------Plugins/
----------------------/comment-reply/
----------------------------comment-reply.php 等文件
- 到管理界面启用Ajax Comments-Reply修订版插件。
- 在index.php中用以下代码显示评论:
<?php $pid=$post->ID; $cnum = get_comments_number(); showcomment($pid, $cnum);?>
插件卸载:
- 将模版目录下备份的comments.php复原。
- 管理界面停用插件或者直接删除此插件文件。
欢迎使用。有任何问题,可在此留言,或者email 到 "qmqsun(AT)gmail.com",当然,也可以去问Zhang-Zi,他的G-talk是"zhang(AT)zhiqiang.org"。
Mar 16, 2007
PLEASE Scroll down for Chinese version
This plugin enables the wp system to convert your dynamic homepage to static index.html, more importantly, keep the content up to date. It can speed up the loading for your homepage.
Readme:
- Plugin WP-Cron is needed for this plugin, I've packed WP-Cron v 1.4 in the zip file.
Please upzip all the files to plugins/static-index, so that it look like:
------plugins/
------------static-index/
----------------static.php
----------------wp-cron-static-index.php
----------------wp-cron.php
- Active two plugins :WP-cron and WP-Cron Static Homepage.
- Create a file named index.html in your blog root folder, set
666 permissions for it.
Well, the system will update index.html automatically (per 15 mins), you may hack wp-cron.php at line 49 to change the time for scheduled exection actions.
More Tips:
- You may use the following php to refresh homepage when comments come in.
<?php
include (get_settings('siteurl') . "/wp-content/plugins/static-index/static.php");
?>
- The following script is to demo how to set cookies in the html files.
<script type="text/javascript">
function GetCookie(sName, id)
{
// cookies are separated by semicolons
var something = document.getElementById(id);
if(!something) return 0;
for (var i=0; i < aCookie.length; i++)
{
// a name alue pair (a crumb) is separated by an equal sign
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
{
if(sName=="comment_author_10add94cfc29a64b08306c8a8f9edb30")
something.value = decodeURI(aCrumb[1]);
else
something.value=unescape(aCrumb[1]);
return 1;
}
}
// a cookie with the requested name does not exist
return 0;
}
//please fill in with your own cookie id
GetCookie("comment_author_8e11b42cc2f3a74aac664cc9afa5baf7", "authorname");
GetCookie("comment_author_email_8e11b42cc2f3a74aac664cc9afa5baf7", "email");
GetCookie("comment_author_url_8e11b42cc2f3a74aac664cc9afa5baf7", "url");</script>
WP Static Homepage(首页静态化)插件的目的是为了将WP的index.php转化为index.html,从而实现首页静态化的目的,提高主页的浏览速度。 如果您想要全站静态化,请参考阅微堂的文章。
安装说明:
- 您需要安装WP-Cron插件,在上述的下载地址中已经包含该插件的1.4版本,您也可以自行下载。
- 将下载文件中的所有文件解压缩后上传到plugins下的static-index目录中,目录结构如下:
------plugins/
----static-index/
------------static.php
------------wp-cron-static-index.php
------------wp-cron.php
- 激活wp-cron,WP-Cron Static Homepage两个插件。
- 在blog根目录建立一个index.html的文件,设置属性为666。
运行之后,系统会每镉15分钟将index.php的内容刷新为index.html,提高浏览速度。 题外话:
- 关于留言问题。 留言系统我采用的也是阅微堂的基于MSN风格的留言系统,该系统基于ajax技术,因此可以在静态页面上使用。如果要使用该留言系统,建议在里面的comment-reply.php文件中包含以下语句,保证留言之后会重新刷新静态主页。
<?php include (get_settings('siteurl') . "/wp-content/plugins/static-index/static.php"); ?>
- 关于cookies读取,在阅微堂的文章中已经有详细的阐述,这里借花献佛,也就是加入如下代码:
<script type="text/javascript">
function GetCookie(sName, id)
{
// cookies are separated by semicolons
var something = document.getElementById(id);
if(!something) return 0;
for (var i=0; i < aCookie.length; i++)
{
// a name alue pair (a crumb) is separated by an equal sign
var aCrumb = aCookie[i].split("=");
if (sName == aCrumb[0])
{
if(sName=="comment_author_10add94cfc29a64b08306c8a8f9edb30")
something.value = decodeURI(aCrumb[1]);
else
something.value=unescape(aCrumb[1]);
return 1;
}
}
// a cookie with the requested name does not exist
return 0;
}
以下为我的cookie设置,用户请自行寻找自己的cookie id
GetCookie("comment_author_8e11b42cc2f3a74aac664cc9afa5baf7", "authorname");
GetCookie("comment_author_email_8e11b42cc2f3a74aac664cc9afa5baf7", "email");
GetCookie("comment_author_url_8e11b42cc2f3a74aac664cc9afa5baf7", "url");</script>
参考文献:
- 阅微堂
- WP-Cron