%
' Comersus 4.00 Sophisticated Cart
' Developed by CopyRight Rodrigo S. Alhadeff
' May-2002
' Open Source License can be found at License.txt
' http://www.comersus.com m
' Details: list active categories on the store. If is leaf category, list products
%>
<%
on error resume next
' set affiliate
if request.querystring("idAffiliate")<>"" and isNumeric(request.querystring("idAffiliate"))then
session("idAffiliate")= request.querystring("idAffiliate")
end if
dim mySQL, connTemp, rsTemp, pIdCategory, pCategoryDesc, totalPages, count
' defined 10 records per page
const numPerPage = 10
if request.queryString("curPage") = "" then
curPage = 1
else
curPage = request.queryString("curPage")
end if
pIdCategory = request.querystring("idCategory")
' get category tree
if pIdCategory<>"" then
dim arrCategories(100,2)
indexCategories = 0
pUrlString = Cstr("")
pIdCategory2=pidCategory
' load category array with all categories until parent
do while pIdCategory2>1
mySQL="SELECT categoryDesc, idCategory, idParentcategory, imageCategory FROM categories WHERE idCategory=" & pIdCategory2
call getFromDatabase (mySql, rsTemp, "listCategoriesAndProducts")
if rstemp.eof then
response.redirect "message.asp?message="&Server.Urlencode(dictLanguage.Item(Session("language")&"_listcategoriesandproducts_6") )
end if
pCategoryDescSw = rsTemp("categoryDesc")
pIdCategorySw = rsTemp("idCategory")
pImageCategory = rsTemp("imageCategory")
call switchCategoryLanguage(session("language"), pIdCategorySw, pCategoryDescSw)
pIdCategory2 = rsTemp("idParentCategory")
arrCategories(indexCategories,0) = pCategoryDescSw
arrCategories(indexCategories,1) = pIdCategorySw
indexCategories = indexCategories + 1
loop
end if 'idParentCategory
' get child categories
if pIdCategory="" then
mySQL="SELECT idCategory, categoryDesc, idParentCategory, imageCategory FROM categories WHERE idParentCategory=1 AND idCategory<>1 ORDER BY categoryDesc"
else
mySQL="SELECT idCategory, categoryDesc, idParentCategory, imageCategory FROM categories WHERE idParentCategory=" &pIdCategory& " AND idCategory<>1 ORDER BY categoryDesc"
end if
call getFromDatabase (mySql, rsTemp, "listCategoriesAndProducts")
' no categories defined in the store
if rstemp.eof and pIdCategory="" then
response.redirect "message.asp?message="&Server.Urlencode(dictLanguage.Item(Session("language")&"_listcategoriesandproducts_1") )
end if
%>
<%
' leaf category, list all products
if rstemp.eof then
mySQL="SELECT products.idProduct, description, price, bTobPrice, smallImageUrl, stock FROM products, categories_products WHERE products.idProduct=categories_products.idProduct AND categories_products.idCategory="& pIdCategory&" AND listHidden=0 AND active=-1 ORDER BY description"
call getFromDatabasePerPage(mySql, rstemp,"listCategoriesAndProducts")
%>
<%
response.write dictLanguage.Item(Session("language")&"_listcategoriesandproducts_2")
for f=indexCategories-1 to 0 step -1
response.write " > " & "" & arrCategories(f,0) &""
next %>