| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 481 人关注过本帖
标题:请教关于静态长文章分页的问题?
只看楼主 加入收藏
yqa611
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2008-10-27
收藏
 问题点数:0 回复次数:0 
请教关于静态长文章分页的问题?
现在的代码是这样的。可以把文章生成如news.html,news_1.html,但是文章的内容却没有分开,第个页面都一样。还有我的分页,可以通过几个分页符生成相应几个页面,但是分页链接只有“上一页”“下一页”,链接地址也没有变。请前辈们指教一下,谢谢。


<%
//获取静态文件名
       fname = makefilename(now()) //makefilename为自定义函数
       folder = "../news/"&left(fname,7)&"/"
       filepath = folder&fname
       html_names = replace(filepath,"../","")
       html_name=html_names&".html"
       html_name_p = replace(filepath,".html","")
      
      
    ContentStr=split(body,"||")//分页符
    PageNumber=ubound(ContentStr)
   
for p=0 to ubound(ContentStr)

   //打开模板代码,并将其中特殊代码转变为接受值
    sql1="select mb_id,mb_body from new_mb where mb_id=2"
       set rs1=Server.CreateObject("adodb.recordset")
       rs1.open sql1,conn,1,1
       mb_code=rs1("mb_body")
       rs1.close
       set rs1=nothing
       conn.close
       set conn=nothing

       body=htmlencode(ContentStr(p))
       mb_code=replace(mb_code,"$htmlbody$",body)


       mb_code=replace(mb_code,"$htmlbody$",body)
       mb_code=replace(mb_code,"$htmltitle$",n_title)
       mb_code=replace(mb_code,"$htmlfor$",n_from)
       mb_code=replace(mb_code,"$htmladmin_xm$",admin_xm)
       mb_code=replace(mb_code,"$htmlclass_name$",class_name)
       mb_code=replace(mb_code,"$htmlask$",sky)

//分页      
if PageNumber>0 then
   MyPagerTable="<table width=""60%"" border=""0"" cellpadding=""0"" cellspacing=""1""><tr><td height=""25""><a href=""$UrlUp""><font color=""ff0000""><strong>[上一页]</strong></font></a></td><td height=""30""><a href=""$UrlDown""><font color=""ff0000""><strong>[下一页]</strong></font></a></td></tr></table>"  //下一页代码,用于替换

   if p<=1 then
   MyPagerTable=replace(MyPagerTable,"$UrlUp","../"&filepath&".html")
                     if p=PageNumber then
                     MyPagerTable=replace(MyPagerTable,"$UrlDown","../"&filepath&"_"&p&".html")
                     else
                     MyPagerTable=replace(MyPagerTable,"$UrlDown","../"&filepath&"_"&p+1&".html")
                     end if
       else
       MyPagerTable=replace(MyPagerTable,"$UrlUp","../"&filepath&"_"&p-1&".html")
                     if p=PageNumber then
                     MyPagerTable=replace(MyPagerTable,"$UrlDown","../"&filepath&"_"&p&".html")
                     else
                     MyPagerTable=replace(MyPagerTable,"$UrlDown","../"&filepath&"_"&p+1&".html")
                     end if
       end if
mb_code=replace(mb_code,"$MyPager$",MyPagerTable)
else
mb_code=replace(mb_code,"$MyPager$","")
end if

//生成页面
Set fso = Server.CreateObject("Scripting.FileSystemObject")
On Error Resume Next //容错处理
fso.CreateFolder(Server.MapPath(folder))
if p=0 then
Set fout = fso.CreateTextFile(Server.MapPath(filepath&".html"))
else
Set fout = fso.CreateTextFile(Server.MapPath(filepath&"_"&p&".html"))
end if
fout.WriteLine mb_code
fout.close

next

%>

sbody=htmlencode(ContentStr(p))里的P不循环,而生成页面里的P却循环,请问怎么回事?
搜索更多相关主题的帖子: 静态 
2008-10-27 15:30
快速回复:请教关于静态长文章分页的问题?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021354 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved