In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly introduces the ASP generated HTML static page and paging how to achieve the relevant knowledge, the content is detailed and easy to understand, simple and fast operation, has a certain reference value, I believe that after reading this ASP to generate HTML static page and paging how to achieve the article will have a harvest, let's take a look.
Related variable parameters: strDir is used to save the folder path of .html file htmlwrite FSO object, used to generate .html file arrcontent by paging tag split article content array InnerPageNum count the number of pages of content rollnum current page (rollnum+1) pagelist page number strTemplate stores template content strTe
1. Related variable parameters:
The folder path used by strDir to save .html files
Htmlwrite FSO object, which is used to generate .html files
Arrcontent Array of article content split by paging label
Number of pages of InnerPageNum statistics content
Rollnum current page (rollnum+1)
Pagelist paging page number
StrTemplate stores template content
StrTemp template content backup
$page_break$ content paging label
2. Core code
'= generate content static page =
On Error resume next
Set fso = Server.CreateObject ("Scripting.FileSystemObject")
'= the path name of the folder used to save the static file, here I set it according to my own project
StrDir=SITEROOT& "/" & NewsHtmlFile& "/" & year (now) & "-" & month (now)
'= generate static file save folder =
If not fso.folderexists (Server.MapPath (strDir)) then fso.CreateFolder (Server.MapPath (strDir))
Set fso=Nothing
If Err=0 then
Dim fso,htmlwrite, arrcontent,InnerPageNum,rollnum,pagelist,strTemplate,strTemp
'= read the template file, my previous article about ASP generating static, with the contents of this data table =
Sql= "SELECT tp_content FROM [KrTemplate] WHERE tp_default=1 AND tp_type=' News content Page template'"
Set rs=Conn.Execute (sql)
If not rs.eof then
StrTemplate=rs (0)
End if
Rs.close
'= back up the template file to prevent it from being overwritten
StrTemp=strTemplate
'= article data sheet =
Sql= "SELECT * FROM [KrNews] WHERE news_html=0 ORDER BY news_date DESC"
Set rs=Conn.Execute (sql)
'= cycle through all the article information to be generated =
Do while not rs.eof
News_keywords=rs ("news_keywords")
News_content=rs ("news_content")
News_tips=rs ("news_tips")
News_name=rs ("news_name")
News_from=rs ("news_from")
News_date=rs ("news_date")
News_id=rs ("news_id")
'= match the content of the article. If a paging tag appears, it will be handled as follows, otherwise it will be processed according to the normal generation method.
If Instr (news_content, "$page_break$") then
'= if the article URL is to be stored in the database, then the address stored here is the path of the first page after the article is paged
Add the logo on the first page to the following URL address. The address I have stored in the database here is like this.
'= URL=URL& "_ 1.html"
URL=SITEURL&strDir& "/ news_" & news_id& ""
'= preprocessing of paging information =
'= put the article content split by paging tag into the array arrcontent=
Arrcontent=split (news_content, "$page_break$")
'= the number of pages obtained after the article is segmented =
InnerPageNum=ubound (arrcontent)
Pagelist= ""
'= cycle to get the page number =
For rollnum=0 to InnerPageNum
Pagelist=pagelist & "[" & (rollnum+1) & "]"
Next
For rollnum=0 to InnerPageNum
'= restore the overwritten template. It is not noticed that the same file will be generated here.
StrTemplate=strTemp
StrTemplate=Replace (strTemplate, "$keywords$", news_keywords)
StrTemplate=Replace (strTemplate, "$news_tips$", news_tips)
. 'Lue, write in the same way
Replace the content of the article and add a paging number
StrTemplate=Replace (strTemplate, "$news_content$", arrcontent (rollnum) & "
Paging: & pagelist&
")
'= path and name of the HTML page to be generated =
Address=strDir& "/ news_" & news_id& "_" & (rollnum+1) & ".html"
'= call the adodb.stream method to generate a static page, which is a custom method, which is attached at the end of the article
WriteToTextFile Address,strTemplate
'= (optional) FSO method to generate static pages
'Set fso = Server.CreateObject ("Scripting.FileSystemObject")
'Set htmlwrite=fso.CreateTextFile (Server.MapPath (Address), true)'/ / create a static page to be generated
'htmlwrite.WriteLine strTemplate' / / write content to the web page
'htmlwrite.close
'set htmlwrite=Nothing
'set fso=Nothing
Next
Else
StrTemplate=Replace (strTemplate, "$keywords$", news_keywords)
StrTemplate=Replace (strTemplate, "$news_tips$", news_tips)
StrTemplate=Replace (strTemplate, "$sitename$", SITENAME)
.
StrTemplate=Replace (strTemplate, "$news_content$", news_content)
Address=strDir& "/ news_" & rs ("news_id") & ".html"
WriteToTextFile Address,strTemplate
End if
Rs.movenext
Loop
Rs.close
End if
'= ADODB.Stream generate file function =
Sub WriteToTextFile (FileUrl,byval Str)
Set stm=server.CreateObject ("adodb.stream")
Stm.Type=2 'reads in this mode
Stm.mode=3
Stm.charset= "GB2312"
Stm.open
Stm.WriteText str
Stm.SaveToFile server.MapPath (FileUrl), 2
Stm.flush
Stm.Close
Str= ""
Set stm=nothing
End Sub
This is the end of the article on "ASP generates HTML static pages and how to achieve paging". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "ASP generates HTML static pages and how to achieve paging". If you want to learn more knowledge, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.