这个文章只是为了抛砖引玉,文中的代码我写的是一个asp代码,作为主题插件呈现出来的,而我单独拿出来这段代码最大的意义,是希望能有更多的人看懂Z-Blog,既然作者不更新,咱们自己动手吧。

[code=vb]<%@ LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
'///////////////////////////////////////////////////////////////////////////////
'// 插件应用: Z-Blog 1.8 +
'// 插件制作: Nobird(http://www.birdol.com)
'// 备 注:
'// 最后修改: 2010-12-29
'// 最后版本: 0.1
'///////////////////////////////////////////////////////////////////////////////
%>
<% Option Explicit %>
<% 'On Error Resume Next %>
<% Response.Charset="UTF-8" %>
<% Response.Buffer=True %>








<%
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
%>

[/code]

这段代码并非仅仅能调用最新文章的摘要,具体调用哪一篇,取决于你的传入参数type。如果这个ID不存在,将会有提示。

下面给出的是一段前台代码的参考,假设上面的代码你保存为ajax_getposts.asp:

[code=js]$("#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();
}
});
});[/code]

剩下的就靠自己发挥了,凡是所有和主题密切相关的插件,几乎没有办法分离成个体,更没有办法说成拿来就能用,多摸索,总会有收获。

  8 Responses to “Z-Blog技巧之调用最新文章的摘要等信息”

  1. 鸟儿哥 我的留言板非常难看(http://www.178yk.tk/guestbook.asp) 还不如留言好看,我看你的颜色应该和我的那个差不多,能否把您的 b_article_comment.html 代码给俺 俺试试呢? 多谢鸟儿大哥了 [GRAVATAR=http://www.birdol.com/]acb31bc1883ad280a90d8044f61b3009[/GRAVATAR]

    nobird 于 2011-6-20 21:27:29 回复

    额 这个不是吧b_article_comment.html 给你就能行的哈,颜色主要是css控制的.你的那个主题我之前试用过, 留言板没这么差吧,你是不是改了什么?

    [GRAVATAR=http://www.birdol.com/]52797216b68380c4331b6e8493245e83[/GRAVATAR]

    水草浪子 于 2011-6-25 12:42:08 回复

    哎 改我倒没改 不过现在好不容易看着日志的代码给改了一下 现在好多了 谢谢鸟儿了~~~

  2. 没看太明白。

    异步装载?

  3. 博主文章,能看出来对zblog研究很深入啊。

  4. 博主这段时间更新很给力啊

  5. 对我有点难,刚用上ZBLOG,从官网上来到你博客的

  6. 不错啊,支持一下,哈哈,够水的评论.

Sorry, the comment form is closed at this time.