这个文章只是为了抛砖引玉,文中的代码我写的是一个asp代码,作为主题插件呈现出来的,而我单独拿出来这段代码最大的意义,是希望能有更多的人看懂Z-Blog,既然作者不更新,咱们自己动手吧。
'///
'// 插件应用: Z-Blog 1.8 +
'// 插件制作: Nobird(http://www.birdol.com)
'// 备 注:
'// 最后修改: 2010-12-29
'// 最后版本: 0.1
'///
%>
Call System_Initialize()
'检查是否启用
If Not LCase(ZC_BLOG_THEME)=LCase("ips") Then Call ShowError(48)
'Dim strReferer
'strReferer=CStr(Request.ServerVariables("HTTP_REFERER"))
'If Instr(strReferer,ZC_BLOG_HOST)=0 Then
'ShowError(5)
'End If
Dim strType
Dim inpID,inpArticle,inpIP,inpAgent
Dim objArticle
strType=Request.QueryString("type")
If strType="post_show" Then
inpID=Request.QueryString("post_show_id")
Call CheckParameter(inpID,"int",0)
Set objArticle=New TArticle
If objArticle.LoadInfoByID(inpID) Then
dim showpostentry:showpostentry=""
showpostentry=showpostentry &""& vbCrLf
showpostentry=showpostentry &"
[ "& Categorys(objArticle.CateID).Name &" ]"& objArticle.Title &"
"& vbCrLf
showpostentry=showpostentry &"
"& vbCrLf
showpostentry=showpostentry &"
"& vbCrLf
showpostentry=showpostentry & objArticle.Intro & vbCrLf
showpostentry=showpostentry &""
showpostentry=showpostentry &""& objArticle.CommNums &" 位潜水员同学成功浮上水面 »" & vbCrLf
showpostentry=showpostentry &"
已有 "& objArticle.ViewNums &" 人阅读 | 生产于"& objArticle.PostTime &" " '//& objArticle.Tag & vbCrLf
showpostentry=showpostentry &"
"& vbCrLf
showpostentry=showpostentry &"
"& vbCrLf
Response.Write showpostentry
Else
Response.Write "数据载入错误, 该文章并不存在!"
End If
Set objArticle=Nothing
End If
Call System_Terminate()
If Err.Number<>0 then
Call ShowError(0)
End If
%>
这段代码并非仅仅能调用最新文章的摘要,具体调用哪一篇,取决于你的传入参数type。如果这个ID不存在,将会有提示。
下面给出的是一段前台代码的参考,假设上面的代码你保存为ajax_getposts.asp:$("#post_show_link_l,#post_show_link_r").click(function(){
//这段代码来自于异次元,iplaysoft.com
// if($(this).attr("rel")=="0")return;
$.ajax({
type: 'GET', dataType: 'html', timeout: '1000',
url: str00+"/themes/ips/plugin/ajax_getposts.asp?type=post_show&post_show_id="+$(this).attr('rel'),
error: function (XMLHttpRequest, textStatus, errorThrown) {
$("#show_post_entry").html('通信失败...');
},
beforeSend:function(){
$("#show_post_entry").html('主人稍等耶,我给你老人家找文章去...');
},
success: function(msg){
$("#show_post_entry").hide();
$("#show_post_entry").html(msg);
$("#show_post_entry").fadeIn();
}
});
});
剩下的就靠自己发挥了,凡是所有和主题密切相关的插件,几乎没有办法分离成个体,更没有办法说成拿来就能用,多摸索,总会有收获。