Hi there,
I needed shopnavcategories.asp to function like shopcategorylist.asp as referenced here:
https://www.vpasp.com/helpnotes/shopexd.asp?id=879
so that categories open shopdisplaycategories.asp and sub-categories open shopdisplayproducts.asp
the shopnavcategories.asp file in the above helpnotes doesn't do this, so I fixed it as shown below. I hope this helps anyone
<%
dim navdbc
'***************************************************************************
sub DisplayNavcategories
shopopendatabaseP navdbc
dim sql, rs, level, rc, catdescription, spacing, categoryid
dim highercategoryid, hassubcategory
highercategoryid=0
GenerateNavsql sql, highercategoryid
set rs=navdbc.execute(sql)
CreateNavCattable
do while not rs.eof
GetNavcategoryfields rs,categoryid, hassubcategory, catdescription, rc
If rc=0 then
spacing=0
FormatNavcategory categoryid, catdescription, spacing, hassubcategory
If hassubcategory<>"" then
FormatNavsubcategories categoryid,spacing
end if
end if
rs.movenext
loop
closerecordset rs
Response.write "</td></tr></table>"
shopclosedatabase navdbc
end sub
Sub CreateNavcattable
Response.write "<table width='100%'>"
response.write "<tr>"
response.write "<td align=left>"
end sub
'
Sub GetNavcategoryfields (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 GenerateNavsql (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_selectnavcategoriesbylanguage sql
sql=sql & " order by " & Getconfig("xsortcategories")
end sub
Sub FormatNavcategory (id, name, spacing, hassubcategory)
dim i
If spacing>0 then
for i = 0 to spacing
response.write " "
next
end if
if hassubcategory <> "" then
response.write "<a href=""shopdisplaycategories.asp?id=" & id & "&cat=" & Server.URLEncode(name) & """>" & name & "</a>" & "<br />" & vbcrlf
else
response.write "<a HREF=""shopdisplayproducts.asp?id=" & id & "&cat=" & Server.URLEncode(name) & """>" & name & "</a>" & "<br>" & vbcrlf
end if
end sub
Sub FormatNavsubcategories (categoryid, spacing)
dim sql, rs, rc, catdescription, hassubcategory
GenerateNavsql sql, categoryid
Set rs=navdbc.execute(sql)
spacing=spacing+1
do while not rs.eof
GetNavcategoryfields rs,categoryid, hassubcategory, catdescription, rc
If rc=0 then
FormatNavcategory categoryid, catdescription, spacing, hassubcategory
If hassubcategory<>"" then
FormatNavsubcategories categoryid, spacing
end if
end if
rs.movenext
loop
spacing=spacing-1
closerecordset rs
end sub
sub Handle_selectnavcategoriesbylanguage (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
%>