%
' Comersus 4.2x Sophisticated Cart
' Developed by Rodrigo S. Alhadeff
' Dic-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
%>
<%
dim mySQL, connTemp, rsTemp, pIdCategory, pCategoryDesc, totalPages, count
call saveCookie()
on error resume next
' set affiliate
pIdAffiliate=getUserInput(request.querystring("idAffiliate"),4)
if isNumeric(pIdAffiliate)then
session("idAffiliate")= pIdAffiliate
end if
' get settings
pDefaultLanguage = getSettingKey("pDefaultLanguage")
pStoreFrontDemoMode = getSettingKey("pStoreFrontDemoMode")
pCurrencySign = getSettingKey("pCurrencySign")
pDecimalSign = getSettingKey("pDecimalSign")
pCompany = getSettingKey("pCompany")
pCompanyLogo = getSettingKey("pCompanyLogo")
pAuctions = getSettingKey("pAuctions")
pListBestSellers = getSettingKey("pListBestSellers")
pNewsLetter = getSettingKey("pNewsLetter")
pPriceList = getSettingKey("pPriceList")
pStoreNews = getSettingKey("pStoreNews")
pOneStepCheckout = getSettingKey("pOneStepCheckout")
pCategoriesAlphOrder = getSettingKey("pCategoriesAlphOrder")
' defined 10 records per page
const numPerPage = 10
if request.queryString("curPage") = "" then
curPage = 1
else
curPage = getUserInput(request.queryString("curPage"),4)
end if
pIdCategory = getUserInput(request.querystring("idCategory"),4)
' 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 AND active=-1"
else
mySQL="SELECT idCategory, categoryDesc, idParentCategory, imageCategory FROM categories WHERE idParentCategory=" &pIdCategory& " AND idCategory<>1 AND active=-1"
end if
if pCategoriesAlphOrder="-1" then
mySql=mySql&" ORDER BY categoryDesc"
else
mySql=mySql&" ORDER BY displayOrder"
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 %>