网络编程
位置:首页>> 网络编程>> Asp编程>> 实现asp长文章自动分页插件

实现asp长文章自动分页插件

  发布时间:2011-02-26 13:51:00 

标签:插件,分页,asp

这是fenye.asp具体代码:


以下是引用片段:




<%
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)<maxPagesize Then
InsertPageBreak=s
End If
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
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 & """>上一页</a> "
Else
ArticleContent = ArticleContent & "<a href="""& m_strFileUrl & CurrentPage - 1 & m_strFileExt & """>上一页</a> "
End If
End If
For i = 1 To Paginate
If i = CurrentPage Then
ArticleContent = ArticleContent & "<font color=""red"">[" & CStr(i) & "]</font> "
Else
If IsURLRewrite And i = 1 Then
ArticleContent = ArticleContent & "<a href="""& ArticleID & m_strFileExt & """>[" & i & "]</a> "
Else
ArticleContent = ArticleContent & "<a href="""& m_strFileUrl & i & m_strFileExt & """>[" & i & "]</a> "
End if
End If
Next
If CurrentPage < Paginate Then
ArticleContent = ArticleContent & " <a href="""& m_strFileUrl & CurrentPage + 1 & m_strFileExt & """>下一页</a>"
End If
ArticleContent = ArticleContent & "</b></p>"
End If
Response.Write(ArticleContent)
End Function
%>

ASP长文章内容自动分页函数

主要功能:自动将长文章内容分页显示,可自由设定分页字数,且不会截断HTML代码。

适用范围:文章内容自动分页插件适用于所有ASP程序。

使用方法:

1.下载附件中的文件,将它解压上传到您的网站根目录fenye.rar (1.42 KB)

2.在需要分页的页面最顶部调用刚刚上传的文件。调用代码 <!--include file="fenye.asp"-->

3.在内容显示处 将原来的显示代码替换为: <%=ContentPagination(您以前的内容显示变量)%>。

0
投稿

猜你喜欢

  • 最近一段时间一直比较忙,已经有好几个月没有打理博客了。现将一个最近在项目中制作的一个菜单实例整理出来,共享一下。在后台或OA系统中最常用到的
  • 我们开发数据库应用时,常常需要用到模糊查询。如果同一个条件需要匹配很多字段怎么办呢?通常,程序员会每个字段都在SQL中“field like
  • 所谓天赋(左脑和右脑)也就是你是否有艺术天赋,天赋也许是存在的,这主要在于人类左右脑的分工。左脑主要负责逻辑理解、语言、判断、分类、分析、推
  • 在做项目的过程中,我们经常会建立各种各样的规范,以方便团队之间更好的合作更好的完成项目;同样我们也经常会听到各种各样的协议,比如Google
  • 介绍分面是指事物的多维度属性。例如一本书包含主题、作者、年代等分面。而分面搜索是指通过事物的这些属性不断筛选、过滤搜索结果的方法。可以将分面
  • 请问论坛的树状记录表是怎么展开的?如何做?论坛的这种展开技术一般采用两种方法实现,一种是采用递归的方法,优点是逻辑简单,编程简单,缺点是速度
  • 代码如下:USE TestDB declare @conversation uniqueidentifier while exists (s
  • asp函数实现把数字格式化为每3个数字时以逗号间隔的数字见下:<%Function Comma(str)If No
  • 问:如何自己制作验证码的head.fix和body.fix文件答:1 图象绘制完成后,将文件存为24位位图格式的BMP图象文件。 2 去除前
  • 工作时常遇到需要在其它地方拷贝样式,比如Firebug之类的,但是复制出来的样式是带有换行和空格的,对于我这种有点洁癖的人来说,经常会一个个
  • 作为一个非设计出生的研究思路偏向的设计师,带着少了设计师自恋和自怜的眼光,我记下最近一年来感受到的交互设计师的尴尬。交互设计师就是出界面的,
  • 今天在一个QQ群中看到有人在问一个进度条的实现方式,当时因为工作时间,需求相对也比较紧,只是简单的说了一下可以通过CSS的边框属性和背景属性
  • 一个很棒的 blog 文章,是 PPK 两年前写的,文章中解释了 contains() 和 compareDocumentPosition(
  • 函数名:FenYe(url,pageCount,recordCount,curPage,cssstyle)   
  • <% a="福建是中国的一个省|我们美丽中国的武夷山!" b="中国,我们,武夷山,福建,美国,苹果&q
  • User Centered Design 以用户为中心的设计,一说到这个很多人马上想到互联网和软件的设计,因为在IT、互联网行业提得最多。其
  • 如何保持数据库中原有格式不变:这些问题在论坛里面几乎天天有人问~!其实当在输入信息,然后提交信息的时候,所有内容的格式是没有变的。只是在当提
  • HTML在线编辑器相信大家见得多了,有些流行的在线编辑器具有很丰富的功能。但美中不足的是,现有的HTML在线编辑器设置字号大小通常只限于1-
  • 原文地址:30 Days of Mootools 1.2 Tutorials - Day 2 - Selectors如果你还没有准备好,请先
  • 由于工作需要,所以前一阵子将IE升级到了8.0,结果今天发现出现一个问题,eWebEditor的在线编辑器不好用了,仔细想想,肯定是IE8搞
手机版 网络编程 asp之家 www.aspxhome.com