关于新闻内容分页

iscooller 2006-07-17 09:35:24
请问:新闻内容太多 一页放不下 什么方法可以分页
以前用过一个函数
<% call ShowArticleContent(Request.QueryString("id"),trim(rs("cont")),913,1)%>

但是在分页结合部会出现文字缺失的情况 ,问:有没有好点的分页方法?
...全文
241 12 打赏 收藏 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
xuStanly 2006-07-18
  • 打赏
  • 举报
回复
Class AutoPaging
'*************************************************************
'目   的:自动将长文章分页输出
'属   性:Splitchar:分页搜索标志。以一维数组方式输入,默认array("<br/>","<BR>","<Br>","<bR>")
'      PagingString:要进行分页的字符串
'      PagingSize:分页长度
'      CurrentPage:当前输出页码
'      DefaultRange:默认搜索分页标志范围
'      StepRange:搜索步长
'方   法:getTotalPageCount():返回总分页数
'      OutputString:输出当前分页内容
'*************************************************************
public Splitchar'分页搜索标志,数组
public PagingString'分页字符串
public PagingSize'页面最大长度
public CurrentPage'当前页码
public DefaultRange'默认起始范围
public StepRange'步长
private Truncate'2维数组m,n。m0=页码、m1=起始字符、m2=结束字符,n=总页数
private intStart'开始位置
private intLen'截取长度
private tmpStr
private Range'起始范围

private Sub Class_Initialize()
Splitchar=array("<br/>","<BR>","<Br>","<bR>")
PagingSize = 2000
DefaultRange=1
StepRange = 1
intStart = 0
intEnd = 0
End Sub

public Function getTotalPageCount()'返回总页数
if len(PagingString) mod PagingSize > 0 then
getTotalPageCount = int(len(PagingString) / PagingSize) + 1
else
getTotalPageCount = len(PagingString) / PagingSize
end if
End Function

public Sub OutputString
redim Truncate(2,getTotalPageCount())

For tmpI = 0 to getTotalPageCount()
Truncate(0,tmpI)=tmpI
Next

For tmpI = 1 to ubound(Truncate,2)
if Truncate(0,tmpI) = 1 then
Truncate(1,tmpI) = 1
else
Truncate(1,tmpI)=Truncate(1,tmpI - 1) + Truncate(2,tmpI - 1)
end if
Range = DefaultRange
Do while Range < PagingSize
tmpStr=right(mid(PagingString,Truncate(1,tmpI),PagingSize),Range)
For tmpInt=0 to ubound(Splitchar)
if instr(1,tmpStr,Splitchar(tmpInt)) > 0 then
Truncate(2,tmpI) = (PagingSize - (len(tmpStr) - instr(1,tmpStr,Splitchar(tmpInt)))) - 1
exit do
end if
Next
Range = Range + StepRange
Loop
if tmpI = Cint(CurrentPage) then
intStart = Truncate(1,tmpI)
intLen = Truncate(2,tmpI)
end if
next
if Cint(CurrentPage) = getTotalPageCount() then
response.write(mid(PagingString,intStart))'如果当前分页为最后一页,则取剩下的所有字符
else
response.write(mid(PagingString,intStart,intLen))
end if
End Sub
End Class

调用示例

set paging=new autopaging
with paging
.pagingstring=Content
.pagingsize=WordLength
.splitchar=array("<br/>","<BR>","<Br>","<bR>","<p>","<P>")
end with
TotalPage = paging.gettotalpagecount()
Page=request("page")
if Page="" or Cint(Page)<1 then
Page=1
else
if Cint(Page) > TotalPage then
Page = TotalPage
else
if CheckValid(Page)=false or not isnumeric(Page) then
response.write("页码参数非法,请返回!")
response.end
end if
end if
end if
paging.currentpage=Page
paging.outputstring
set paging=nothing
分页页码部分:
<%
if TotalPage > 1 then
For i=1 to TotalPage
if i = Cint(Page) then
response.write("<b>" & i & "</b> ")
else
response.write("<a href=readnews.asp?newsid=" & NewsID & "&bigclassid=" & BigClassID & "&smallclassid=" & SmallClassid & "&specialid=" & SpecialID & "&page=" & i & ">[" & i & "]</a> ")
end if
Next
end if
%>

应用示例
http://www.chceg.com/readnews.asp?newsid=227&bigclassid=9&smallclassid=36&specialid=5

缺陷,输出内容中不可包含table标签。

如果都只在最后一页显示,可能原因为字符中不包含
Splitchar=array("<br/>","<BR>","<Br>","<bR>")
中指定的字符,Splitchar数组的内容你可以用array()自己定义,上面几项是类的默认值。
ice241018 2006-07-18
  • 打赏
  • 举报
回复
期待更好的分页方法
lyfer 2006-07-18
  • 打赏
  • 举报
回复
楼上所说的支持自动分页.这个其实还是他自己写了一个分页函数.他就是在添加内容时用JS实时判断输入文字的多少,然后根据文字个数自动加入分页特殊标记.这个我觉得不好,会让用户觉得麻烦.看了也不舒服
ice241018 2006-07-18
  • 打赏
  • 举报
回复
渐飞和新云cms有
xuStanly 2006-07-18
  • 打赏
  • 举报
回复
请参考楼上中我的回复。
xuStanly 2006-07-18
  • 打赏
  • 举报
回复
参考
http://community.csdn.net/Expert/topic/4871/4871013.xml?temp=5.239505E-02
iscooller 2006-07-17
  • 打赏
  • 举报
回复
新闻内容分页
underone 2006-07-17
  • 打赏
  • 举报
回复
分页方法有很多,关键看你需要什么样子的了
houhaijun 2006-07-17
  • 打赏
  • 举报
回复
有吗?哪里可以下载到啊!讲一下
ice241018 2006-07-17
  • 打赏
  • 举报
回复
有一种编辑器支持自动分页
只需要插入分页标记就可以了
houhaijun 2006-07-17
  • 打赏
  • 举报
回复
用这个挺好的:

<%
sub autopage()
dim Maxpagelen,page,content,PageNumber,ArticleID
dim contentlen
dim BeginPoint,EndPoint

Maxpagelen=1000
content=cstr(rs("content"))
xwid=rs("xwid")
contentlen=len(content)
page=request.QueryString("page")

if contentlen<=Maxpagelen then
response.Write content
else
if page="" then
page=1
else
page=Cint(page)
end if

if pageNumber*MaxPagelen<contentlen then
PageNumber=PageNumber+1
end if
PageNumber=int(contentlen/Maxpagelen)+1
if page<1 then page=1
if page>PageNumber then page=PageNumber
if page=1 then
BeginPoint=1
else
BeginPoint=MaxPagelen*(page-1)+1
end if
if page=PageNumber then
EndPoint=contentlen
else
EndPoint=MaxPagelen*page
if EndPoint>=ContentLen then
EndPoint=ContentLen
end if
end if

content=Mid(content,BeginPoint,EndPoint-BeginPoint)
response.Write content
response.Write"<br>"
response.Write"<br>"
response.Write"<br>"

end if
for i=1 to PageNumber
response.Write "<a href=news_show.asp?xwid=" & xwid &"&page=" & i & "> "& i &"</a>"
Next
end sub
%>
lyfer 2006-07-17
  • 打赏
  • 举报
回复
自已写一个看怎么调怎么调呀

28,402

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧