无限分类生成HTML文件

本文介绍了一种通过递归查询数据库获取文章分类信息,并根据分类深度及路径生成对应的HTML文件的方法。具体包括如何构建文件路径、创建文件夹及生成文件内容。
'无限分类生成HTML文件


'接收传递过来的文章路径参数

set rsHtmlFileCode=server.CreateObject ("ADODB.RecordSet")
sql4="select * from Article where ID="&CurrentArticleID
rsHtmlFileCode.Open sql4,conn,1,3
if rsHtmlFileCode.EOF and rsHtmlFileCode.bof then
response.Write("alert('没有找到需要生成HTML的文章数据内容');history.go(-1);")
response.End()
else

ClassDepth=rs("ClassDepth")
ClassID=rs("ClassID")
ParentID=rs("ParentID")
'获取当前文章路径
if ClassDepth=0 then
CurrentClassDir="/"&sClassDir
else
sClassDepth=ClassDepth-1
sParentID=ParentID
CurrentClassDir=""
GetCurrentClassDirPath sClassDepth,sParentID,CurrentClassDir
end if
'建立当前文章目录
CreatHtmlFolder CurrentClassDir

end if
rsHtmlFileCode.close
set rsHtmlFileCode=nothing

'获取文章对应的静态生成页面文件路径
Function GetCurrentClassDirPath(CurrentClassDepth,CurrentClassID,CurrentClassDir)

set rsClsssDirPath=server.CreateObject ("ADODB.RecordSet")
sqlClsssDirPath="select * from ArticleClass where ParentID="&CurrentClassID
rsClsssDirPath.Open sqlClsssDirPath,conn,1,3
if rsClsssDirPath.EOF and rsClsssDirPath.bof then
response.Write("alert('没有找到需要生成HTML的文章数据内容');history.go(-1);")
response.End()
else

sClassDepth=rsClsssDirPath("ClassDepth")-1
sParentID=rsClsssDirPath("ParentID")
sClassDir=rsClsssDirPath("ClassDir")

if sClassDepth=0 then

if CurrentClassDir="" then
'当前文章的类别是顶类下的文章的路径
StrClassDir="/"&sClassDir
else
'多级类别下的文章的路径
StrClassDir=sClassDir&"/"&CurrentClassDir
end if
Exit Function
else
CurrentClassDir=sClassDir&"/"&CurrentClassDir
GetCurrentClassDirPath sClassDepth,sParentID,CurrentClassDir
end if
end if
rsClsssDirPath.close
set rsClsssDirPath=nothing

end Function

'建立对应的文件夹
Function CreatHtmlFolder(CurrentFolderName)
CurrentFolderPath=Server.MapPath(CurrentFolderName)
Set FolderObject=Server.CreateObject("Scripting.FileSystemObject")
if not FolderObject.FolderExists(CurrentFolderPath) then
FolderObject.CreateFolder(CurrentFolderPath)
response.Write(CurrentFolderPath&"文件夹创建完成")
else
response.Write(CurrentFolderPath&"文件夹已存在")
end if
set FolderObject=nothing
end Function

'建立对应的文件内容
Function CreatHtmlFile(ClassDirPath,FileName,FileExt,ArticleID,HtmlContentCode)
Set fso = CreateObject("scripting.FileSystemObject")
HtmlFileName=ClassDirPath&"/"&HtmlFileName&"."&HtmlFileExt
HtmlFileNamePath=Server.MapPath(HtmlFileNamePath)
Set ObjHtmlFile=fso.OpenTextFile(HtmlFileNamePath,8,True)

ObjHtmlFile.WriteLine HtmlContentCode

ObjHtmlFile.Close
Set ObjHtmlFile=Nothing
end Function

系统支持无限级分类、采集、生成静态HTML、ajax 自定义表单 系统标签说明: 的标签结构形如(ror标签): #{…/} 或 #{…}***{/} 内嵌标签: 标签: ##.../# 如同#{…/} 在#{…/}中使用 字段值:[$$$/] 其中 … 是标签参数 ***是循环调用的模块 $$$是字段名 具体标签及说明如下: 1、#{host fieldname=hostname/} 说明: 系统参数: 网站名称: fieldname=hostname 关键字: fieldname=hostkey 虚拟目录: fieldname=hosturl 2、#{param=classname/} 说明: 访问页面的各种通用参数: 栏目名称: param=classname 文档名称: param=title URL参数: param=*** 特别说明: 当栏目类型为单页面时,调用单页面内容使用param=content 3、#{ position /} 说明:当前位置 4、#{ menu /} Top: 显示数量,默认为10 Menutype: 菜单属性,默认顶级栏目菜单 Top:顶级栏目菜单 Self:同级栏目菜单 Sun:下级栏目菜单 Typelink: 相应栏目的链接地址 5、#{clalist …/} 或 #{clalist …}***{/} 说明:部分栏目文档列表(没有分页) Top: 读取的文档数目,默认10 Titlelen: 标题显示长度,默认30 Showtitle: 鼠标悬停时是否显示完整标题,默认不显示 Orderby: 排序字段,默认id(当order为rnd时可以不设置) Order: 顺序,默认降序(升序:asc 降序:desc 随机:rnd ) Classid: 所属栏目(0和all都表示所有栏目) all:按栏目显示相应数目的文档 0: 不按栏目显示相应数目的文档 clacol: 循环块列数 artcol: 文档列表列数 clastyle: 每个循环块的样式 artstyle: 每个循环块中文档列表区域的样式 Maxlen: 各个字段的最大显示长度,默认100 Textlink: 形如:*** Typelink: 相应文档的链接地址(…) Imglink: 形如: Imgheight:图片高度 Imgwidth:图片宽度 Arttype: 文档属性 Image: 图片 Slide: 幻灯 Roll: 滚动 Common: 普通 Good: 推荐 #{clalist …/}:不用设置***,系统默认为textlink 嵌套标签:{class}…[classtext/] [classlink/]…{/class} 说明:classtext 栏目名 classlink 栏目链接 6、#{artlist …/} 或 #{artlist …}***{/} 说明:全部栏目文档列表(有分页)属性类似于clalist 没有Showclass及设置其属性的各种标签 Pagelist:分页列表 Search:搜索页使用标签,关键字自定义字段值,默认为key 7、#{art_view}***{/} 说明:文档显示页标签 可以显示文档的各个字段值,如:title,hits,content,ctime等 #{Prenext/}:显示上一篇、下一篇 8、#{pl }***{/} 9、#{book }***{/} 更多、更详细的标签自己在使用中来发现哦!~~~
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值