📄 cl_function_product.asp
字号:
End Function
'=================================================
'过程名:ShowClassProduct(sChannelID,sClassID,ModNum,TopNum)
'参 数:
' sChannelID ---- 频道ID
' sClassID ---- 指定栏目,多个用“|”分隔,不指定请留空或0
' ModNum --- 多少个换行
' TopNum --- 最多显示记录数
'=================================================
Function ShowClassProduct(Byval sChannelID,Byval sClassID,Byval ModNum,Byval TopNum)
Dim sqlRoot,rsRoot,ClassCount,iClassID,nClassID
Dim sTemp,strValue,ClassLinkUrl
sChannelID = Cl.GetClng(sChannelID)
sClassID = Trim(sClassID)
ModNum = Cl.GetClng(ModNum)
if sClassID="" or sClassID="0" then
TopNum = Cl.GetClng(TopNum)
if TopNum=0 then TopNum = 6
sqlRoot="select Top "&TopNum&" ClassID,ClassName,ParentPath,ClassDir,ParentDir,RootID,Child,arrChildID,Readme From Cl_Class where ChannelID="&sChannelID&" and ParentID=0 and IsElite="&TrueType&" and IsOuter=0 order by RootID"
Else
sqlRoot="select ClassID,ClassName,ParentPath,ClassDir,ParentDir,RootID,Child,arrChildID,Readme From Cl_Class where ChannelID="&sChannelID&" and IsElite="&TrueType&" and IsOuter=0 and ClassID In ("&Replace(sClassID,"|",",")&") order by RootID"
End if
Set rsRoot= Cl.Execute(sqlRoot)
if rsRoot.bof and rsRoot.eof then
sTemp="还没有任何栏目,请首先添加栏目。"
rsRoot.Close:Set rsRoot=Nothing:Exit Function
end if
sqlRoot=rsRoot.GetRows(-1)
rsRoot.Close:Set rsRoot=Nothing
Dim TemplateHTMLStr
TemplateHTMLStr = Template.GetTemplate(Cl.GetDefaultTemplateID(5,9,Template.ProjectID))
TemplateHTMLStr = Replace(TemplateHTMLStr,"{$webdir}",InstallDir)
TemplateHTMLStr = Replace(TemplateHTMLStr,"{$csspicurl}",Cl.WebDir & Cl.CssPicUrl)
TemplateHTMLStr = Split(TemplateHTMLStr,"@@@")
'If ChannelID=0 Then ChannelID = sChannelID
nClassID = Ubound(sqlRoot,2)
for iClassID=0 to nClassID
ClassID = sqlRoot(0,iClassID)
ClassLinkUrl = Cl.GetClassLinkUrl(sqlRoot(0,iClassID))
strValue=TemplateHTMLStr(1)
strValue=Replace(strValue,"{$channelid}",sChannelID)
strValue=Replace(strValue,"{$classid}",sqlRoot(0,iClassID))
strValue=Replace(strValue,"{$classtitle}",sqlRoot(8,iClassID)&"")
strValue=Replace(strValue,"{$classname}",sqlRoot(1,iClassID))
strValue=Replace(strValue,"{$classfileurl}",ClassLinkUrl)
strValue=Replace(strValue,"{$classlinkurl}",ClassLinkUrl)
strValue=Template.ReplaceFlag(strValue,"showproduct","")
If iClassID<nClassID then
if ((iClassID+1) mod ModNum) = 0 then
strValue = strValue & TemplateHTMLStr(3)
else
strValue = strValue & TemplateHTMLStr(2)
end If
End if
sTemp=sTemp & strValue
Next
ShowClassProduct=Replace(TemplateHTMLStr(0),"{$classproductbody}",sTemp)
TemplateHTMLStr = Null
sqlRoot=Empty
End Function
'====================================================================================================
'过程:ShowPicProduct(sChannelID,sClassID,sSpecialID,TopNum,TitleLen,ShowType,Cols,ImgWidth,ImgHeight,ContentLen,IsHot,IsElite)
'参数:
' sChannelID ------ 频道ID
' sClassID ------ 栏目ID(0为所有栏目,若大于0,则调用指定栏目及其子栏目)
' sSpecialID ------ 专题ID(0为所有栏目,若大于0,则调用指定地区)
' TopNum ------ 最多显示多少篇
' TitleLen ------ 标题最多字符数
' ShowType ------ 显示方式。0(图),1(图+标),2(图+标+内),3(图+幻),4(图+标+幻)
' Cols ------ 列数。超过此列数就换行
' ImgWidth ------ 图片宽度
' ImgHeight ------ 图片高度
' ContentLen ------ 内容最多字符数
' IsHot ------ 是否是热门(True为是,False为否)
' IsElite ------ 是否是推荐(True为是,False为否)
'====================================================================================================
Function ShowPicProduct(Byval sChannelID,Byval sClassID,Byval sSpecialID, _
Byval TopNum,Byval TitleLen,Byval ShowType,Byval Cols,Byval ImgWidth, _
Byval ImgHeight,Byval ContentLen,Byval IsHot,Byval IsElite)
On Error Resume Next
sChannelID = Clng(sChannelID) : sClassID = Clng(sClassID)
sSpecialID = Clng(sSpecialID) : TopNum = Clng(TopNum)
TitleLen = Clng(TitleLen) : ShowType = Clng(ShowType)
Cols = Clng(Cols) : ImgWidth = Clng(ImgWidth)
ImgHeight = Clng(ImgHeight) : ContentLen = Clng(ContentLen)
IsHot = CBool(IsHot) : IsElite = CBool(IsElite)
if Err then Err.Clear : ShowPicProduct="ShowPicProduct参数错误。":Exit Function
On Error GoTo 0
dim rsPic,sqlPic,tClass,j,strPic
if TopNum<=0 then
sqlPic="Select "
else
sqlPic="Select top "&TopNum&" "
end if
sqlPic=sqlPic & " InfoID,ChannelID,ChannelDir,ClassID,ProductName,Prefixion,ProductSn,Producer,Trademark,ProductModel,ProductUnit,Intro,MarketPrice,MemberPrice,TruePrice,Discount,IncludeTax,TaxRate,InfoPoint,StockNum,PresentExp,PicUrl,OnTop,Hot,Elite,Stars,Hits,BuyTimes,UpdateTime,Editor,Status,IsHtml,HtmlFileUrl from Cl_Product where Deleted="&FalseType&" and Status=1 and PicUrl<>'' "
if sChannelID>0 then sqlPic=sqlPic & " and ChannelID="&sChannelID&" "
if sClassID>0 then
set tClass=Cl.Execute("select ClassID,Child,ParentPath,arrChildID from Cl_Class where ChannelID="&sChannelID&" and ClassID=" & sClassID)
if not(tClass.bof and tClass.eof) then
if tClass(1)>0 then
sqlPic=sqlPic & " and ClassID in (" & tClass(3) & ")"
else
sqlPic=sqlPic & " and ClassID=" & sClassID
end if
else
sqlPic=sqlPic & " and ClassID=" & sClassID
end if
set tClass=Nothing
end if
if sSpecialID>0 then sqlPic=sqlPic & " and SpecialID Like '%," & sSpecialID & ",%'"
if IsHot=True then sqlPic=sqlPic & " and Hot="&TrueType&" "
if IsElite=True then sqlPic=sqlPic & " and Elite="&TrueType&" "
if IsSqlDataBase=1 then
sqlPic=sqlPic & " order by OnTop Desc,UpdateTime desc,InfoID desc"
Else
sqlPic=sqlPic & " order by OnTop Asc,UpdateTime desc,InfoID desc"
End if
Set rsPic= Server.CreateObject("ADODB.Recordset")
OpenConn : rsPic.open sqlPic,Conn,1,1
if rsPic.bof and rsPic.eof then
strPic = strPic & "<img src=""" & Cl.WebDir & "images/NoPic.gif"" width=""" & ImgWidth & """ height=""" & ImgHeight & """ border=""0"">"
rsPic.Close : Set rsPic = Nothing
else
dim FileType,TitleStr,LinkUrl
if TopNum<=0 or TopNum>=100 then
TotalPut=rsPic.recordcount
if (TotalPut mod PageSize)=0 then
TotalPages = TotalPut \ PageSize
else
TotalPages = TotalPut \ PageSize + 1
end if
if CurrentPage > TotalPages then CurrentPage=TotalPages
if CurrentPage < 1 then CurrentPage=1
rsPic.move (CurrentPage-1)*PageSize
sqlPic = rsPic.GetRows(PageSize)
else
sqlPic=rsPic.GetRows(-1)
end if
rsPic.Close : Set rsPic = Nothing
Select Case ShowType
Case 0
strPic = "<table width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" align=""center""><tr>"
for j=0 to Ubound(sqlPic,2)
if sqlPic(31,j) then
LinkUrl=Cl.WebDir & sqlPic(32,j)
else
LinkUrl=Cl.WebDir & sqlPic(2,j) & "/ShowInfo.asp?InfoID=" & sqlPic(0,j)
end if
strPic = strPic & "<td align=""center"">"
FileType=right(lcase(sqlPic(21,j)),3)
strPic = strPic & "<a href=""" & LinkUrl & """ title=""" & sqlPic(4,j) & """ target=""_blank"">"
sqlPic(21,j)=Cl.ReplaceDir(sqlPic(21,j))
Select Case FileType
Case "swf"
strPic = strPic & "<object classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"" codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"" width=""" & ImgWidth & """ height=""" & ImgHeight & """><param name=""movie"" value=""" & sqlPic(21,j) & """><param name=""quality"" value=""high""><embed src=""" & sqlPic(21,j) & """ pluginspage=""http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"" type=""application/x-shockwave-flash"" width=""" & ImgWidth & """ height=""" & ImgHeight & """></embed></object>"
Case "jpg", "bmp", "png", "gif"
strPic = strPic & "<img src=""" & sqlPic(21,j) & """ width=""" & ImgWidth & """ height=""" & ImgHeight & """ border=""0"">"
Case else
strPic = strPic & "<img src=""" & Cl.WebDir & "images/NoPic.gif"" width=""" & ImgWidth & """ height=""" & ImgHeight & """ border=""0"">"
end Select
strPic = strPic & "</a></td>"
if (j+1) Mod Cols=0 then strPic = strPic & "</tr><tr valign=""top"">"
Next
strPic = strPic & "</tr></table>"
Case 1
strPic = "<table width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" align=""center""><tr>"
for j=0 to Ubound(sqlPic,2)
if sqlPic(31,j) then
LinkUrl=Cl.WebDir & sqlPic(32,j)
else
LinkUrl=Cl.WebDir & sqlPic(2,j) & "/ShowInfo.asp?InfoID=" & sqlPic(0,j)
end if
strPic = strPic & "<td align=""center"">"
FileType=right(lcase(sqlPic(21,j)),3)
TitleStr=Cl.GotTopic(sqlPic(4,j),TitleLen)
strPic = strPic & "<a href=""" & LinkUrl & """ title=""" & sqlPic(4,j) & """ target=""_blank"">"
sqlPic(21,j)=Cl.ReplaceDir(sqlPic(21,j))
Select Case FileType
Case "swf"
strPic = strPic & "<object classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"" codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"" width=""" & ImgWidth & """ height=""" & ImgHeight & """><param name=""movie"" value=""" & sqlPic(21,j) & """><param name=""quality"" value=""high""><embed src=""" & sqlPic(21,j) & """ pluginspage=""http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"" type=""application/x-shockwave-flash"" width=""" & ImgWidth & """ height=""" & ImgHeight & """></embed></object>"
Case "jpg", "bmp", "png", "gif"
strPic = strPic & "<img src=""" & sqlPic(21,j) & """ width=""" & ImgWidth & """ height=""" & ImgHeight & """ border=""0"">"
Case else
strPic = strPic & "<img src=""" & Cl.WebDir & "images/NoPic.gif"" width=""" & ImgWidth & """ height=""" & ImgHeight & """ border=""0"">"
end Select
strPic = strPic & "<br />" & TitleStr & "</a>"
strPic = strPic & "</td>"
if (j+1) Mod Cols=0 then strPic = strPic & "</tr><tr valign=""top"">"
Next
strPic = strPic & "</tr></table>"
Case 2
strPic = "<table width=""100%"" cellpadding=""0"" cellspacing=""0"" border=""0"" align=""center""><tr>"
for j=0 to Ubound(sqlPic,2)
if sqlPic(31,j) then
LinkUrl=Cl.WebDir & sqlPic(32,j)
else
LinkUrl=Cl.WebDir & sqlPic(2,j) & "/ShowInfo.asp?InfoID=" & sqlPic(0,j)
end if
strPic = strPic & "<td align=""center"">"
FileType=right(lcase(sqlPic(21,j)),3)
TitleStr=Cl.GotTopic(sqlPic(4,j),TitleLen)
strPic = strPic & "<td align=""center""><table width=""100%"" cellspacing=""2"" border=""0"">"
strPic = strPic & " <tr><td align=""center"" width="""&ImgWidth+2&""">"
strPic = strPic & "<a href=""" & LinkUrl & """ title=""" & sqlPic(4,j) & """ target=""_blank"">"
sqlPic(21,j)=Cl.ReplaceDir(sqlPic(21,j))
Select Case FileType
Case "swf"
strPic = strPic & "<object classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"" codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0"" width=""" & ImgWidth & """ height=""" & ImgHeight & """><param name=""movie"" value=""" & sqlPic(21,j) & """><param name=""quality"" value=""high""><embed src=""" & sqlPic(21,j) & """ pluginspage=""http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"" type=""application/x-shockwave-flash"" width=""" & ImgWidth & """ height=""" & ImgHeight & """></embed></object>"
Case "jpg", "bmp", "png", "gif"
strPic = strPic & "<img src=""" & sqlPic(21,j) & """ width=""" & ImgWidth & """ height=""" & ImgHeight & """ border=""0"">"
Case else
strPic = strPic & "<img src=""" & Cl.WebDir & "images/NoPic.gif"" width=""" & ImgWidth & """ height=""" & ImgHeight & """ border=""0"">"
end Select
strPic = strPic & "<br />" & TitleStr & "</a>"
strPic = strPic & "</td><td valign=""top"" algin=""left"" class=""left"">简 介:"&left(sqlPic(11,j),ContentLen) & "……</a><br /><br />"
strPic = strPic & "市场价:<STRIKE>¥" & sqlPic(12,j) &"</STRIKE><br />"
strPic = strPic & "会员价:¥" & Cl.FormatColor(sqlPic(13,j),"#ff0033") &"<br />"
strPic = strPic & "<a href="""&Cl.WebDir & "User/Cart.asp?InfoID=" & sqlPic(0,j) & """ target=""_blank""><img src=""" & Cl.WebDir & "images/Product/Buy.gif"" border=0></a> <a href=""" & LinkUrl & """ title=""" & sqlPic(4,j) & """ target=""_blank""><img src=""" & Cl.WebDir & "images/Product/Content.gif"" border=0></a></td></tr>"
strPic = strPic & "</table></td>"
if (j+1) Mod Cols=0 then strPic = strPic & "</tr><tr valign=""top"">"
Next
strPic = strPic & "</tr></table>"
Case 3, 4
Dim sImgID, FirstPicUrl
sImgID=Cl.CreatePass(3) & "Cl" & ImgWidth & ImgHeight & ContentLen' & IsHot & IsElite
strPic = "<script type=""text/javascript"">" & vbcrlf
strPic = strPic & "<!--" & vbcrlf
strPic = strPic & "var AImg"&sImgID&"=new Array();" & vbcrlf
strPic = strPic & "var AImg"&sImgID&"link=new Array();" & vbcrlf
strPic = strPic & "var AImg"&sImgID&"title=new Array();" & vbcrlf
strPic = strPic & "var adNum"&sImgID&"=0;" & vbcrlf
For j=0 to Ubound(sqlPic,2)
if j=0 then FirstPicUrl=Cl.ReplaceDir(sqlPic(21,j))
TitleStr = Cl.GotTopic(sqlPic(4,j),TitleLen)
'TitleStr = Cl.GetTitleFont(TitleStr,sqlPic(9,j))
'TitleStr = Cl.FormatColor(TitleStr,sqlPic(8,j))
if CBool(sqlPic(31,j)) then
LinkUrl=Cl.WebDir & sqlPic(32,j)
else
LinkUrl=Cl.WebDir & sqlPic(2,j) & "/ShowInfo.asp?InfoID=" & sqlPic(0,j)
end if
strPic = strPic & "AImg"&sImgID&"link[" & cStr(j) & "]=""" & LinkUrl & """;" & vbcrlf
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -