ASP long article content automatic paging Function

Source: Internet
Author: User

<%
Const maxpagesize = 1000 'set the number of pagination words

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) <maxpagesize then
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 <Len (s) then
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 = "</" & findarray (I)
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
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 = "<Div id =" "newscontentlabel" "class =" "newscontent"> "& strcontent &" </div> <Div id = "" message "" class = """ message ""> </div>"
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 = "<Div id =" "newscontentlabel" "class =" "newscontent"> "& arrcontent (currentpage-1)

Articlecontent = articlecontent & strcontent
If userarticle = true then
Articlecontent = articlecontent & "</P> </div> <Div id =" "message" "class =" "message" "> </div> <p align = "" center ""> <B>"
Else
Articlecontent = articlecontent & "</P> </div> <p align =" "center"> <B>"
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 & "<a href =" & ArticleID & m_strfileext & ""> previous page </a> & nbsp ;"
Else
Articlecontent = articlecontent & "<a href =" & m_strfileurl & currentpage-1 & m_strfileext & ""> previous page </a> & nbsp ;"
End if
End if
For I = 1 to paginate
If I = currentpage then
Articlecontent = articlecontent & "<font color =" red "> [" & CSTR (I) & "] </font> & nbsp ;"
Else
If isurlrewrite and I = 1 then
Articlecontent = articlecontent & "<a href =" & ArticleID & m_strfileext & ""> ["& I &"] </a> & nbsp ;"
Else
Articlecontent = articlecontent & "<a href =" & m_strfileurl & I & m_strfileext & ""> ["& I &"] </a> & nbsp ;"
End if
End if
Next
If currentpage <paginate then
Articlecontent = articlecontent & "& nbsp; <a href =" & m_strfileurl & currentpage + 1 & m_strfileext & ""> next page </a>"
End if
Articlecontent = articlecontent & "</B> </P>"
End if
Response. Write (articlecontent)
End Function
%>

 

ASP long article content automatic paging Function

Main function: automatically display the long article content on pages. You can set the number of words on pages without interrupting the HTML code.

Scope of application: the automatic paging plug-in applies to all ASP programs.

Usage:

1. download the file in the attachment and decompress it to upload it to the root directory of your website.

2. Call the uploaded file at the top of the page to be paged. Call Code
<! -- Include file = "contentautopage. asp" -->

3. In the content display area, replace the original display code with: <% = contentpagination (RS ("variable field") %>.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.