<% ' 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 ' Details: list active categories on the store and child categories %> <% on error resume next dim mySQL, connTemp, rsTemp, pIdCategory, pCategoryDesc 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") ' get child categories mySQL="SELECT idCategory, categoryDesc, idParentCategory FROM categories WHERE idParentCategory=1 AND idCategory<>1 ORDER BY categoryDesc" call getFromDatabase (mySql, rsTemp, "listCategoriesTree") ' no categories defined in the store if rstemp.eof then response.redirect "message.asp?message="&Server.Urlencode(dictLanguage.Item(Session("language")&"_listCategoriesTree_1") ) end if %>

<%=dictLanguage.Item(Session("language")&"_listCategoriesTree_2")%>
<% ' iterates through the child categories do while not rstemp.eof pIdCategory = rstemp("idCategory") pCategoryDesc = rstemp("categoryDesc") pIdParentCategory = rstemp("idParentCategory") ' check if there is another language defined to show for that category switchCategoryLanguage session("language"), pIdCategory, pCategoryDesc ' if is child show the link to products, if not show the description if isChildCategory(pIdCategory)=-1 then response.write "

"&pCategoryDesc&"" else response.write "

"&pCategoryDesc end if ' get child categories (recursive) call getChildCategories(pIdCategory,1,0) rstemp.moveNext loop call closeDb() %>
<% function getChildCategories(idParentCategory2, idPreviousParentCategory, tabs) dim mySql2, rstemp2 mySql2="SELECT idCategory, categoryDesc, idParentCategory FROM categories WHERE idParentCategory=" &idParentCategory2&" ORDER BY categoryDesc" call getFromDatabase (mySql2, rsTemp2, "listCategoriesTree") do while not rstemp2.eof pCategoryDesc2 =rstemp2("categoryDesc") pIdCategory2 =rstemp2("idCategory") switchCategoryLanguage session("language"), pIdCategory2, pCategoryDesc2 response.write "
" if idPreviousParentCategory<>idParentCategory2 then if idPreviousParentCategory>idParentCategory2 then tabs = tabs-1 else tabs = tabs+1 end if idPreviousParentCategory = idParentCategory2 end if for f=1 to tabs response.write " " next if isChildCategory(pIdCategory2)=-1 then response.write ""&pCategoryDesc2&"" else response.write pCategoryDesc2 end if call getChildCategories(pIdCategory2, idPreviousParentCategory, tabs) rstemp2.movenext loop end function function isChildCategory(idCategory) dim mySql3, rstemp3 mySQL3="SELECT idCategory FROM categories WHERE idParentCategory=" &idCategory call getFromDatabase (mySql3, rsTemp3, "listCategoriesTree") if rstemp3.eof then isChildCategory=-1 else isChildCategory=0 end if end function %>