把PJBlog换成全动态—自动分页!

2009年6月30日 | 分类: 代码如诗 | 标签: , , ,

把PJBlog换成全动态了。因为有比较长的文章发表,早就想换了,但是根据论坛的大人修改了好几次都不成功…..[face11]。静态动态都不OK,所以好久都没弄,几天重看了【情留メ蚊子】的自动分页代码,终于下决心用他了,这里感谢下。

下面是修改方法,贴出来吧!这个方法只支持全动态,支持PJ2 3,要改的朋友看清楚了。

打开class/cls_article.asp,找到:
[code] If log_ViewArr(10, 0) = 1 Then
response.Write (highlight(UnCheckStr(UBBCode(HtmlEncode(log_ViewArr(8, 0)), Mid(log_ViewArr(11, 0), 1, 1), Mid(log_ViewArr(11, 0), 2, 1), Mid(log_ViewArr(11, 0), 3, 1), Mid(log_ViewArr(11, 0), 4, 1), Mid(log_ViewArr(11, 0), 5, 1))), keyword))
Else
response.Write (highlight(UnCheckStr(log_ViewArr(8, 0)), keyword))
End If[/code]

替换成:
[code] dim Content
If log_ViewArr(10, 0) = 1 Then
content=highlight(UnCheckStr(UBBCode(HtmlEncode(log_ViewArr(8, 0)), Mid(log_ViewArr(11, 0), 1, 1), Mid(log_ViewArr(11, 0), 2, 1), Mid(log_ViewArr(11, 0), 3, 1), Mid(log_ViewArr(11, 0), 4, 1), Mid(log_ViewArr(11, 0), 5, 1))), keyword)
ContentPagination(Content)
Else
content=highlight(UnCheckStr(log_ViewArr(8, 0)), keyword)
ContentPagination(Content)
End If[/code]
[pagebreak]
在最后加入一下:
[code]
<%
Const maxPagesize=1000 '设置分页字数

Function InsertPageBreak(strText)
Dim strPagebreak,s,ss
Dim i,IsCount,c,iCount,strTemp,Temp_String,Temp_Array
strPagebreak="[hiweb_break]"
s=strText
If Len(s) InsertPageBreak=s
End If
s=Replace(s, strPagebreak, "")
s=Replace(s, "&nbsp;", "<&nbsp;>")
s=Replace(s, "&gt;", "<&gt;>")
s=Replace(s, "&lt;", "<&lt;>")
s=Replace(s, "&quot;", "<&quot;>")
s=Replace(s, "&#39;", "<&#39;>")
If s<>"" and maxPagesize<>0 and InStr(1,s,strPagebreak)=0 then
IsCount=True
Temp_String=""
For i= 1 To Len(s)
c=Mid(s,i,1)
If c="<" Then
IsCount=False
ElseIf c=">" Then
IsCount=True
Else
If IsCount=True Then
If Abs(Asc(c))>255 Then
iCount=iCount+2
Else
iCount=iCount+1
End If
If iCount>=maxPagesize And i strTemp=Left(s,i)
If CheckPagination(strTemp,"table|a|b>|i>|strong|div|span") then
Temp_String=Temp_String & Trim(CStr(i)) & ","
iCount=0
End If
End If
End If
End If
Next
If Len(Temp_String)>1 Then Temp_String=Left(Temp_String,Len(Temp_String)-1)
Temp_Array=Split(Temp_String,",")
For i = UBound(Temp_Array) To LBound(Temp_Array) Step -1
ss = Mid(s,Temp_Array(i)+1)
If Len(ss) > 380 Then
s=Left(s,Temp_Array(i)) & strPagebreak & ss
Else
s=Left(s,Temp_Array(i)) & ss
End If
Next
End If
s=Replace(s, "<&nbsp;>", "&nbsp;")
s=Replace(s, "<&gt;>", "&gt;")
s=Replace(s, "<&lt;>", "&lt;")
s=Replace(s, "<&quot;>", "&quot;")
s=Replace(s, "<&#39;>", "&#39;")
InsertPageBreak=s
End Function

Function CheckPagination(strTemp,strFind)
Dim i,n,m_ingBeginNum,m_intEndNum
Dim m_strBegin,m_strEnd,FindArray
strTemp=LCase(strTemp)
strFind=LCase(strFind)
If strTemp<>"" and strFind<>"" then
FindArray=split(strFind,"|")
For i = 0 to Ubound(FindArray)
m_strBegin="<"&FindArray(i)
m_strEnd =" n=0
do while instr(n+1,strTemp,m_strBegin)<>0
n=instr(n+1,strTemp,m_strBegin)
m_ingBeginNum=m_ingBeginNum+1
Loop
n=0
do while instr(n+1,strTemp,m_strEnd)<>0
n=instr(n+1,strTemp,m_strEnd)
m_intEndNum=m_intEndNum+1
Loop
If m_intEndNum=m_ingBeginNum then
CheckPagination=True
Else
CheckPagination=False
Exit Function
End If
Next
Else
CheckPagination=False
End If
End Function

Function ContentPagination(hiwebstr)
Dim ContentLen, maxperpage, Paginate
Dim arrContent, strContent, i,CurrentPage,ArticleContent,UserArticle,IsURLRewrite
Dim m_strFileUrl,m_strFileExt,ArticleID
ArticleID=Request.QueryString("ID")
strContent = InsertPageBreak(hiwebstr)
ContentLen = Len(strContent)
CurrentPage=Request.QueryString("Page")
If CurrentPage="" Then CurrentPage=0
If InStr(strContent, "[hiweb_break]") <= 0 Then
ArticleContent = "

" & strContent & "

"
Else
arrContent = Split(strContent, "[hiweb_break]")
Paginate = UBound(arrContent) + 1
If CurrentPage = 0 Then
CurrentPage = 1
Else
CurrentPage = CLng(CurrentPage)
End If
If CurrentPage < 1 Then CurrentPage = 1
If CurrentPage > Paginate Then CurrentPage = Paginate
strContent = "

"& arrContent(CurrentPage - 1)

ArticleContent = ArticleContent & strContent
If UserArticle = True Then
ArticleContent = ArticleContent & "

"
Else
ArticleContent = ArticleContent & "

"
End If
If IsURLRewrite Then
m_strFileUrl = ArticleID & "_"
Else
m_strFileExt = ""
m_strFileUrl = "?id=" & ArticleID & "&Page="
End If
If CurrentPage > 1 Then
If IsURLRewrite And (CurrentPage-1) = 1 Then
ArticleContent = ArticleContent & "上一页 "
Else
ArticleContent = ArticleContent & "上一页 "
End If
End If
For i = 1 To Paginate
If i = CurrentPage Then
ArticleContent = ArticleContent & "[" & CStr(i) & "] "
Else
If IsURLRewrite And i = 1 Then
ArticleContent = ArticleContent & "[" & i & "] "
Else
ArticleContent = ArticleContent & "[" & i & "] "
End if
End If
Next
If CurrentPage < Paginate Then
ArticleContent = ArticleContent & " 下一页"
End If
ArticleContent = ArticleContent & "

"
End If
Response.Write(ArticleContent)
End Function
%>[/code]

这样就OK了。

目前还没有任何评论.