风易博客

风萧萧兮易水寒, 壮士一去兮不复还。

« 程序人生之编程九重经营危机并不等于经济危机 »

Z-BLOG v1.8自定义首页调用

会说话的博客,点我试试:)

最新修改:03/02/2009,配合 列表插件,可以达到更好的效果。无缝继承了19种列表,提供了包括(文章排行,随机文章)等多种文章列表等。

刚从PJBLOG转到Z-BLOG,还不是很习惯,Z-BLOG内置的首页调用不错,但是不太适合我的需要,为此,特改造一个自定义的最新日志调用。只显示日志标题,并自动用CSS截取多余的字符长度,超链接在新窗口打开。用法很简单,把以下代码保存为一个新文件,然后上传到z-blog根目录,并在外部调用之,调用条数可以在z-blog后台修改,调用代码如下: <script type="text/javascript" charset="utf-8" src="http://1982y.net.cn/topblog.asp"></script>,可根据需要改成自己的z-blog地址。

预览:http://www.wind88.net

源代码如下:
 

ASP/Visual Basic代码
  1. <%@ CODEPAGE=65001 %>   
  2. <%   
  3. '==================================   
  4. '首页调用文件 topBlog.asp   
  5. '风易博客 http://1982Y.Net.Cn   
  6. %>   
  7. <% Option Explicit %>   
  8. <% On Error Resume Next %>   
  9. <% Response.Charset="UTF-8" %>   
  10. <% Response.Buffer=True %>   
  11. <% Response.ContentType="application/x-javascript" %>   
  12. <!-- #include file="c_option.asp" -->   
  13. <!-- #include file="function/c_function.asp" -->   
  14. <!-- #include file="function/c_system_base.asp" -->   
  15. <% 
  16. '新增代码
  17. Dim actKey : actKey = Request.QueryString("act")
  18. If actKey = "" Then actKey = "previous"  
  19.  
  20. Response.Clear 
  21. Response.Write "document.write(""" & LoadFileInfo("previous") & """)"  
  22. Response.End  
  23.   
  24. Function LoadFileInfo(name)   
  25.   
  26.     Dim strContent,str   
  27.     Dim objStream   
  28.   
  29.     Dim i,j   
  30.   
  31.     Dim aryTemplateTagsName   
  32.     Dim aryTemplateTagsValue   
  33.   
  34.     Application.Lock   
  35.     aryTemplateTagsName=Application(ZC_BLOG_CLSID & "TemplateTagsName")   
  36.     aryTemplateTagsValue=Application(ZC_BLOG_CLSID & "TemplateTagsValue")   
  37.     Application.UnLock   
  38.   
  39.     j=UBound(aryTemplateTagsName)   
  40.   
  41.     For i=1 to j   
  42.         If aryTemplateTagsName(i)="TEMPLATE_INCLUDE_" & UCase(name) Then  
  43.             strContent=aryTemplateTagsValue(i)   
  44.             Exit For  
  45.         ElseIf aryTemplateTagsName(i)="CACHE_INCLUDE_" & UCase(name) Then  
  46.             strContent=aryTemplateTagsValue(i)   
  47.         End If  
  48.     Next  
  49.   
  50.     Dim reg, objMatches   
  51.     Set reg = new RegExp   
  52.     reg.IgnoreCase = True  
  53.     reg.Global = True  
  54.   
  55.     '一日期,二日期,三标题   
  56.     reg.Pattern = "(http://[^\s]+)"".+?span.+?\[(.+?)\].+?>(.+?)<"  
  57.     Set objMatches = reg.Execute(strContent)   
  58.     If objMatches.Count > 0 Then  
  59.         For i = 0 To objMatches.Count - 1   
  60.             str = str & "<div style='width:145px;overflow:hidden;white-space:nowrap;word-break:keep-all;text-overflow:ellipsis;'><a href="""&objMatches(i).SubMatches(0)""" target=""_blank"" title="""&toUnicode(objMatches(i).SubMatches(2))""" style=""color:#0469C4;TEXT-DECORATION: none"">"&toUnicode(objMatches(i).SubMatches(2))"</a></div>"  
  61.         Next  
  62.     End If  
  63.        
  64.     str= Replace(str,"\","\\")  
  65.     str= Replace(str,"/","\/")  
  66.     str= Replace(str,"""","'")   
  67.     str= Replace(str,vbCrLf,"")  
  68.     str= Replace(str,vbLf,"")   
  69.   
  70.     LoadFileInfo=str   
  71.   
  72. End Function  
  73.   
  74. function toUnicode(str) 'To Unicode   
  75.     dim i, unicodeF, getUnicode   
  76.     for i=1 to len(str)   
  77.         unicodeF=Mid(str,i,1)   
  78.         getUnicode=getUnicode & chr(38) & chr(35) & chr(120) & Hex(ascw(unicodeF)) & chr(59)   
  79.     next   
  80.     toUnicode=getUnicode   
  81. end function   
  82. %>  

最后,我们还需要改动列表插件的一个函数,如下:PLUGIN\busfly_randomsort\index.asp,在约219行至250行的位置,替换为如下函数

 

ASP/Visual Basic代码
  1. '*********************************************************   
  2. ' 目的:    列表记录的数据   
  3. ' 参数说明:    
  4. ' b_objRS => 数据集合   
  5. ' strOutName => 保存到include时的名字(不带后缀名)   
  6. ' out_count => 多少条记录   
  7. '*********************************************************   
  8. Function busfly_randomsort_outArticleHtml(ByVal b_objRS,ByVal strOutName,ByVal out_count)   
  9.     dim i   
  10.     dim strOut   
  11.     strOut=" "  
  12.        
  13.     If (Not b_objRS.bof) And (Not b_objRS.eof) Then  
  14.         For i=1 to out_count   
  15.             Set busfly_randomsort_objArticle=New TArticle   
  16.             If busfly_randomsort_objArticle.LoadInfoByID(b_objRS("log_ID")) Then  
  17.                 strOut=strOut & "<li><a href="""& busfly_randomsort_objArticle.Url & """ title=""" & busfly_randomsort_strReplace(busfly_randomsort_objArticle.Title,busfly_randomsort_chReplace) & """><span class=""article-date"">["&Right("0"&Month(busfly_randomsort_objArticle.PostTime),2)"/"&Right("0"&Day(busfly_randomsort_objArticle.PostTime),2)"]</span>" & busfly_randomsort_cutTitle(busfly_randomsort_objArticle.Title,busfly_randomsort_INTCUTLEN) & "</a></li>"    
  18.             End If  
  19.             Set busfly_randomsort_objArticle=Nothing  
  20.             b_objRS.MoveNext   
  21.             If b_objRS.eof Then Exit For  
  22.         Next  
  23.     End If  
  24.     b_objRS.close   
  25.   
  26.     strOut=TransferHTML(strOut,"[no-asp]")   
  27.   
  28.     Call SaveToFile(BlogPath & "/include/"&strOutName".asp",strOut,"utf-8",True)   
  29.   
  30.     strOut=""  
  31. End Function  
  32. '*********************************************************  

 

  • 相关文章:
  • quote 1.gogogo
  • 很好,找了很久终于让我找到了,但发现为什么我套用你的代码后出错的呢?我的blog不是网站根目录下,是在根目录的/blog/下的,出现错误如下:

    Microsoft VBScript 编译器错误 错误 '800a0401'

    语句未结束

    /blog/topblog.asp,行 56

    str = str & "<div style='width:145px;overflow:hidden;white-space:nowrap;word-break:keep-all;text-overflow:ellipsis;'><a href="""&objMatches(i).SubMatches(0)""" target=""_blank"" title="""&toUnicode(objMatches(i).SubMatches(2))""" style=""color:#0469C4;TEXT-DECORATION: none"">"&toUnicode(objMatches(i).SubMatches(2))"</a></div>"
  • 2008-11-17 8:52:41 回复该留言
  • quote 3.gogogo
  • 你好,请麻烦帮我测试一下,我的blog地址是:http://blog.leying.org/blog/topblog.asp
  • 2008-11-21 2:12:35 回复该留言
  • quote 4.清风
  • 你是不是改动了什么代码?

    我把我的提供给你下载查看: http://1982y.net.cn/topblog.rar
  • 2008-11-24 13:57:57 回复该留言
  • quote 5.gogogo
  • 谢谢你的源程序,但是为什么我把你的源程序上传后运行后是空白的?再次请教
  • 2008-11-25 19:48:57 回复该留言
  • quote 6.gogogo
  • 请问调用条数在zblog的哪里可以修改阿?我找了很久都找不到。
  • 2008-11-25 19:55:07 回复该留言
  • quote 7.清风
  • 你好,可能是你网站服务器设置的原因,看不到具体的出错信息,建议你在本地搭建IIS来测试.

    调用条数在后台,网站设置管理,页面设置,最近发表文章的数量
  • 2008-11-26 20:42:45 回复该留言
  • quote 8.gogogo
  • 我后台设置显示的是15 条文章,现在下载你的rar解压上传后提示是这样阿:

    document.write("")   请问应该如何解决了?奇怪,为什么我的无法输出阿?
  • 2008-11-26 23:22:52 回复该留言
  • quote 10.Partoo
  • 很好的文章,我收藏了,另外,开头的代码有点问题,下载包里的很正确;还有就是
    “我们还需要改动列表插件的一个函数,如下:PLUGIN\busfly_randomsort\index.asp,在约219行至250行的位置,替换为如下函数”
    在我这里是
    PLUGIN\busfly_randomsort\include.asp



  • 2009-4-9 20:12:24 回复该留言

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表

Powered By Z-Blog 1.8 Spirit Build 80722 Code detection by Codefense  theme by BokeZhuti

Copyright © 2005 - 2008 风易博客 1982Y.Net.Cn All Rights Reserved.  由Wind88.Net提供优质主机空间
沪ICP备05006417号