<%option explicit%> <% '*************************************************************************** ' display all categories and their subcategories ' VP-ASP 5.00 ' Jan 3, 2003 '***************************************************************************** dim dbc shoppageheader shopopendatabaseP dbc Displaycategories shopclosedatabase dbc shoppagetrailer '*************************************************************************** sub Displaycategories dim sql, rs, level, rc, catdescription, spacing, categoryid dim highercategoryid, hassubcategory highercategoryid=0 Generatesql sql, highercategoryid set rs=dbc.execute(sql) CreateCattable do while not rs.eof Getcategoryfields rs,categoryid, hassubcategory, catdescription, rc If rc=0 then spacing=0 Formatcategory categoryid, catdescription, spacing If hassubcategory<>"" then Formatsubcategories categoryid,spacing end if end if rs.movenext loop closerecordset rs Response.write "" end sub Sub Createcattable Response.write "" response.write "" response.write "
" end sub ' Sub Getcategoryfields (rs, categoryid, hassubcategory, strcategory, rc) dim strcathide categoryid=rs("categoryid") strcategory=rs("catdescription") hassubcategory=rs("hassubcategory") If isnull(hassubcategory) then hassubcategory="" end if strcathide=rs("cathide") ' hide field if isnull(strcathide) then rc=0 else rc=4 end if end sub Sub Generatesql (sql, highercategoryid) SQL="Select * from categories " sql = Sql & " where highercategoryid=" & highercategoryid if getconfig("xproductmatch")="Yes" then sql=sql & " and productmatch='" & xproductmatch & "'" end if if getconfig("xproductmatchcustomer")="Yes" then if GetSess("CustomerProductGroup")<>"" then sql=sql & " and customermatch='" & getsess("customerProductgroup") & "'" end if end if Handle_selectcategoriesbylanguage sql sql=sql & " order by " & Getconfig("xsortcategories") end sub Sub Formatcategory (id, name, spacing) dim i If spacing>0 then for i = 0 to spacing response.write "  " next end if response.write "" & name & "" & "
" & vbcrlf end sub Sub Formatsubcategories (categoryid, spacing) dim sql, rs, rc, catdescription, hassubcategory Generatesql sql, categoryid Set rs=dbc.execute(sql) spacing=spacing+1 do while not rs.eof Getcategoryfields rs,categoryid, hassubcategory, catdescription, rc If rc=0 then Formatcategory categoryid, catdescription, spacing If hassubcategory<>"" then Formatsubcategories categoryid, spacing end if end if rs.movenext loop spacing=spacing-1 closerecordset rs end sub sub Handle_selectcategoriesbylanguage (sql) If getconfig("xselectproductsbylanguage")="Yes" and getsess("language")<>"" then sql=sql & " and (catlanguage='" & getsess("language") & "'" sql=sql & " or catlanguage is null)" end if end sub %>