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. '*********************************************************  

 

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

最新评论及回复

  • pengyoupengyou | 2009-10-8 20:00:58
  • Z-BLOG v1.8自定义首页调用怎样配合列表插件,我非常想知道? 谢谢! 能生成静态的列表吗?
  • 回复该留言
  • pengyoupengyou | 2009-10-8 0:12:30
  • Z-BLOG v1.8自定义首页调用

    这个功能太好了,我一直在找。

    但有个问题,能不能调用后,生成静态的,在首页源文件能看到最新调用博客文章条数的文字,这个在搜索引擎收录更新起着关键性作用,非常利于搜索排名。



    清风 于 2009-10-8 16:58:10 回复
    回复 pengyou

    ZBLOG已经是全站缓存模式,不需要生成静态就可以达到减轻系统负担的目的.

    站外调用,一种是JS模式,一种是IFRAME模式,除此之外就要重写程序代码,这可能需要根据特定情况定制了.
    pengyou 于 2009-10-10 13:03:09 回复
    清风:你好!我想定制,需要多收费用,请发到我邮箱。

    我的目的:我的博客程序在我网站根目录下建了个文件夹www.abc.com/BLOG/ , 博客写的最新内容的标题可以调用到网站首页、和我需要的内容页,并生成静态文字链接。
  • 回复该留言
  • PartooPartoo | 2009-4-9 20:12:24
  • 很好的文章,我收藏了,另外,开头的代码有点问题,下载包里的很正确;还有就是
    “我们还需要改动列表插件的一个函数,如下:PLUGIN\busfly_randomsort\index.asp,在约219行至250行的位置,替换为如下函数”
    在我这里是
    PLUGIN\busfly_randomsort\include.asp



  • 回复该留言
  • gogogogogogo | 2008-11-26 23:22:52
  • 我后台设置显示的是15 条文章,现在下载你的rar解压上传后提示是这样阿:

    document.write("")   请问应该如何解决了?奇怪,为什么我的无法输出阿?
  • 回复该留言
  • 清风清风 | 2008-11-26 20:42:45
  • 你好,可能是你网站服务器设置的原因,看不到具体的出错信息,建议你在本地搭建IIS来测试.

    调用条数在后台,网站设置管理,页面设置,最近发表文章的数量
  • 回复该留言
  • gogogogogogo | 2008-11-25 19:55:07
  • 请问调用条数在zblog的哪里可以修改阿?我找了很久都找不到。
  • 回复该留言
  • gogogogogogo | 2008-11-25 19:48:57
  • 谢谢你的源程序,但是为什么我把你的源程序上传后运行后是空白的?再次请教
  • 回复该留言
  • 清风清风 | 2008-11-24 13:57:57
  • 你是不是改动了什么代码?

    我把我的提供给你下载查看: http://1982y.net.cn/topblog.rar
  • 回复该留言
  • gogogogogogo | 2008-11-21 2:12:35
  • 你好,请麻烦帮我测试一下,我的blog地址是:http://blog.leying.org/blog/topblog.asp
  • 回复该留言
  • gogogogogogo | 2008-11-17 8:52:41
  • 很好,找了很久终于让我找到了,但发现为什么我套用你的代码后出错的呢?我的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>"
  • 回复该留言

发表评论

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

网站分类

相关文章

最近发表

最新评论及回复

Powered By Z-Blog 1.8 Arwen Build 90619

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