<%@ LANGUAGE="VBSCRIPT" %> <% PageStrings = "18, 31, 55, 57, 107, 108, 149, 150, 151, 152, 153, 154, 158, 160, 161, 265, 266, 648, 897, 898, 1231, 1236, 1237, 1442, 1443, 1458, 1490, 1659, 1673, 1688, 1689, 1703, 1704, 1782, 1791, 1792, 1806, 1807" %> <% '=============================================== ' CactuShop ASP Shopping Cart ' ©1999-2007 Cactusoft International FZ-LLC ' www.cactusoft.com '=============================================== ' All rights reserved. ' Use of this code is covered by the terms and ' conditions in the license agreement. No ' unauthorized duplication or distribution is ' permitted. Cactusoft's copyright notices must ' remain in the ASP sections of the code. '=============================================== '----------------------------------------------- 'COLLECT VALUES 'See if we call pull out the ID at the end 'Defensive coding as the querystring could 'contain pretty much anything, and we need to 'handle it. '----------------------------------------------- '----------------------------------------------- 'COLLECT VALUES '----------------------------------------------- 'Get category ID - may be from 404 data, or from querystring Set objDynamicLinks = New DynamicLinks Call objDynamicLinks.Build(request.QueryString, objRecordSet) If objDynamicLinks.PageType = "category" then CAT_ID = objDynamicLinks.CatID numRecordPosition = objDynamicLinks.CatRecordPosition Else CAT_ID = NumSafe(DualRequest("CAT_ID")) numRecordPosition = NumSafe(request.querystring("numRecordPosition")) End If 'If we haven't got a page, set it to 1 If numRecordPosition = 0 then numRecordPosition = 1 '----------------------------------------------- 'PULL OUT PRODTYPE FROM DATABASE '----------------------------------------------- blnNoShow = false strQuery = "SELECT CAT_Name" & CInt(numLanguageID) & ", CAT_ProductDisplayType, CAT_SubCatDisplayType, CAT_Desc" & CInt(numLanguageID) & ", CAT_OrderProductsBy FROM tblCactuShop" & TABLE_PREFIX & "Categories WHERE CAT_Live='y' AND CAT_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND CAT_ID=" & CAT_ID Call ExecuteRS(strQuery, objRecordSet) If not (objRecordSet.BOF and objRecordSet.EOF) then CAT_Name = objRecordSet("CAT_Name" & CInt(numLanguageID) & "") CAT_ProductDisplayType = objRecordSet("CAT_ProductDisplayType") CAT_SubCatDisplayType = objRecordSet("CAT_SubCatDisplayType") CAT_Desc = objRecordSet("CAT_Desc" & CInt(numLanguageID)) CAT_OrderProductsBy = objRecordSet("CAT_OrderProductsBy") blnNoShow = objRecordSet("CAT_Name" & CInt(numLanguageID)) & "" = "" 'Set the string to use as the title of this page - good for search engines! strPageTitleHTML = CAT_Name & GetString("PageTitle_Separator") & GetString("Config_Webshopname") strMetaDescHTML = left(CAT_Desc, 300) Else CAT_ProductDisplayType = "d" CAT_SubCatDisplayType = "d" CAT_ID = "0" 'Set the string to use as the title of this page - good for search engines! strPageTitleHTML = GetString("ContentText_Categories") & GetString("PageTitle_Separator") & GetString("Config_Webshopname") strMetaDescHTML = "" End if If GetAppVar("convertdescbreaks") = "y" then CAT_Desc = replace(CAT_Desc & "", vbcrlf, "
") end if objRecordSet.close '----------------------------------------------- 'BUILDPAGE (done lower for meta tags) '----------------------------------------------- %> <% '*********************************************** 'GET OUT ALL THE PRODUCTS 'We do this now because the page links comes 'quite early on. '*********************************************** '----------------------------------------------- 'SET ORDERING CLAUSE 'Get the ordering from prodtype or config '----------------------------------------------- strProductsOrderBy = GetAppVar("sortproducts") If CAT_OrderProductsBy <> "" then strProductsOrderBy = CAT_OrderProductsBy if strProductsOrderBy = "" then strProductsOrderBy = "P_Name" 'If the orderby is a 'languaged'-field, then stick on the numerical language ID If strProductsOrderBy = "P_Name" or strProductsOrderBy = "P_Desc" or strProductsOrderBy = "P_StrapLine" or strProductsOrderBy = "P_SpecTable" or strProductsOrderBy = "P_Hyperlink" then strProductsOrderBy = strProductsOrderBy & CInt(numLanguageID) end if '----------------------------------------------- 'PULL OUT PRODUCTS FROM DATABASE 'First list the selects. If the orderby isn't 'in the selects, then add it on to the end. The 'add on the rest of the query (otherwise you 'get a 'conflicts with DISTINCT error') 'DISTINCTROW stops descriptions getting truncated 'at 255 characters. ' 'If strAppShowPriceOnProductDisplay turned on, 'then we select a MIN(V_Price), and need to group 'by all the other selects. Don't do this if it's 'turn off as it slows down the query. '----------------------------------------------- strAppShowPriceOnProductDisplay = GetAppVar("showpriceonproductdisplay") 'If using access, append products table name for casting if strDatabaseType = "access" then strTblProd = "tblCactuShop" & TABLE_PREFIX & "Products." else strTblProd = "" strSelectValues = "CAT_ID, P_ID, P_VersionDisplayType, P_OrderVersionsBy, P_StrapLine" & CInt(numLanguageID) & ", " & strTblProd & castSQL("P_Desc" & CInt(numLanguageID)) & " as P_Desc" & CInt(numLanguageID) & ", P_Name" & CInt(numLanguageID) & ", P_Type" StrSelectValues2 = Replace(strSelectValues, "as P_Desc" & CInt(numLanguageID),"") if instr(strSelectValues, strProductsOrderBy) = 0 then strSelectValues = strSelectValues & ", " & strProductsOrderBy strSelectValues2 = strSelectValues2 & ", " & strProductsOrderBy end if If strAppShowPriceOnProductDisplay = "y" then strQuery = "SELECT " & strDistinctRowStatement & " " & strSelectValues & ", MIN(V_Price) As MinPrice, MIN(T_TaxRate) As MinTaxRate FROM ((((tblCactuShop" & TABLE_PREFIX & "Categories c INNER JOIN tblCactuShop" & TABLE_PREFIX & "ProductCategoryLink pcl ON c.CAT_ID = pcl.PCAT_CategoryID) INNER JOIN tblCactuShop" & TABLE_PREFIX & "Products ON pcl.PCAT_ProductID = tblCactuShop" & TABLE_PREFIX & "Products.P_ID) INNER JOIN tblCactuShop" & TABLE_PREFIX & "Versions v ON tblCactuShop" & TABLE_PREFIX & "Products.P_ID = v.V_ProductID) INNER JOIN tblCactuShop" & TABLE_PREFIX & "TaxRates t on v.V_Tax = t.T_ID) LEFT OUTER JOIN tblCactuShop" & TABLE_PREFIX & "Suppliers s ON tblCactuShop" & TABLE_PREFIX & "Products.P_SupplierID = s.SUP_ID WHERE P_Name" & CInt(numLanguageID) & " <> '' AND V_Live = 'y' AND V_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND P_Live = 'y' AND P_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND CAT_Live = 'y' AND CAT_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND CAT_ID=" & CAT_ID & " AND (SUP_Live <> 'n' OR SUP_Live IS NULL) GROUP BY " & strSelectValues2 & " ORDER BY " & strProductsOrderBy Else strQuery = "SELECT " & strDistinctRowStatement & " " & strSelectValues & " FROM (((tblCactuShop" & TABLE_PREFIX & "Categories INNER JOIN tblCactuShop" & TABLE_PREFIX & "ProductCategoryLink ON tblCactuShop" & TABLE_PREFIX & "Categories.CAT_ID = tblCactuShop" & TABLE_PREFIX & "ProductCategoryLink.PCAT_CategoryID) INNER JOIN tblCactuShop" & TABLE_PREFIX & "Products ON tblCactuShop" & TABLE_PREFIX & "Products.P_ID = tblCactuShop" & TABLE_PREFIX & "ProductCategoryLink.PCAT_ProductID) INNER JOIN tblCactuShop" & TABLE_PREFIX & "Versions ON tblCactuShop" & TABLE_PREFIX & "Versions.V_ProductID = tblCactuShop" & TABLE_PREFIX & "Products.P_ID) LEFT OUTER JOIN tblCactuShop" & TABLE_PREFIX & "Suppliers ON tblCactuShop" & TABLE_PREFIX & "Products.P_SupplierID = tblCactuShop" & TABLE_PREFIX & "Suppliers.SUP_ID WHERE P_Name" & CInt(numLanguageID) & " <> '' AND V_Live = 'y' AND P_Live = 'y' AND V_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND P_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND CAT_Live = 'y' AND CAT_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") AND CAT_ID=" & CAT_ID & " AND (SUP_Live <> 'n' OR SUP_Live IS NULL) ORDER BY " & strProductsOrderBy End If Call ExecuteRS(strQuery, objRecordSet) 'Move to correct record for the start of the page numRecordCount = objRecordSet.RecordCount If numRecordCount > 0 then objRecordSet.AbsolutePosition = numRecordPosition end if '----------------------------------------------- 'SET VALUES FOR ITEMS PER PAGE 'Note that rows and columns are determined from 'the CSS, not in config settings (as was the 'case in prior CactuShop versions). Instead, you 'specify how many items per page are shown in 'shortformat, and then size the width of these 'items in CSS. The browser fits as many as it 'can per line. '----------------------------------------------- 'These need to be set here so the top paging works 'Display type - defaults should be set to the application setting If CAT_ProductDisplayType = "d" then CAT_ProductDisplayType = GetAppVar("defaultproddisplay") If CAT_SubCatDisplayType = "d" then CAT_SubCatDisplayType = GetAppVar("defaultprodtypedisplay") If CAT_ProductDisplayType = "s" then numProdsPerPage = GetAppVar("shortformatpagesize") else numProdsPerPage = GetAppVar("prodtypepagesize") end if '----------------------------------------------- 'READ PAGE TEMPLATE FROM FILE '----------------------------------------------- Call ReadFromTemplate(strTemplateLocation, aryPageTemplate) '----------------------------------------------- 'WRITE FIRST HALF OF PAGE HTML '----------------------------------------------- response.write(aryPageTemplate(0)) 'Set image stuff - must come after readfromtemplate Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject") aryFileTypes = Split(GetAppVar("allowedimages"), ",") strAppUploadsFolder = GetAppVar("uploadsfolder") strCategoryPath = Server.MapPath(strTemplateShopFolder & strAppUploadsFolder & "images_categories/") strCategoryLargePath = Server.MapPath(strTemplateShopFolder & strAppUploadsFolder & "images_categories_large/") strVersionPath = Server.MapPath(strTemplateShopFolder & strAppUploadsFolder & "images_versions/") strVersionLargePath = Server.MapPath(strTemplateShopFolder & strAppUploadsFolder & "images_versions_large/") strProductPath = Server.MapPath(strTemplateShopFolder & strAppUploadsFolder & "images_products/") If blnNoShow then 'Category not found - display message %>

<% WriteString("ContentText_ProdTypeUnavailable") %>

<% else '*********************************************** 'DISPLAY HEADER 'Location bar, pagination, trail, category details '*********************************************** Set objTrail = New BreadCrumbTrail 'Set overrides if needed If objDynamicLinks.PageType = "category" then objTrail.Parents = objDynamicLinks.CatParents objTrail.PageHistory = objDynamicLinks.PageHistory End If 'Get keyword search array if we're from the search If objTrail.PageHistory = "search" then aryKeywords = CreateKeywordArray(objCactuSession.Value("search_keywords"), objCactuSession.Value("search_searchcriteria")) End If If CAT_ID = 0 then 'Set the page history to category objTrail.PageHistory = "category" 'Just show the title %>

<% WriteString("ContentText_Categories") %>

<% else 'Build the trail and write it out Call objTrail.Build(objRecordSet2, CAT_ID, CAT_Name, "") response.write "

" & CAT_Name & "

" & vbcrlf response.Write objTrail.ToHTML 'Next/Prev Links %> <% if strPageLinks <> "" then %>
<% =strPageLinks %>
<% end if %>
<% '----------------------------------------------- 'CATEGORY '----------------------------------------------- strThumbnailHTML = "" strLargeImageHTML = "" 'Find and show normal image (if it exists) strThumbnailImage = GetFileLocation(strCategoryPath, CAT_ID, aryFileTypes, objFileSystem) If strThumbnailImage <> "" Then strThumbnailHTML = "" End If 'Find and show link to popup of large image (if it exists) strLargeImage = GetFileLocation(strCategoryLargePath, CAT_ID, aryFileTypes, objFileSystem) If strLargeImage <> "" Then If gfxSpex(strCategoryLargePath & "\" & strLargeImage, numWidth, numHeight, numDepth, strType) = True Then strImage = strLargeImage strImageType = "category" strLargeLink = "" strThumbnailHTML = vbcrlf & strLargeLink & strThumbnailHTML & "" strLargeHTML = vbcrlf & "
" & strLargeLink & GetString("ContentText_LargeView") & "
" End if End if 'Show image strText = strThumbnailHTML & "

" & CAT_Desc & "

" & strLargeHTML If strText <> "" then response.write "
" & vbcrlf response.write strText & vbcrlf response.write "
" & vbcrlf end if end if '*********************************************** 'LIST SUB-CATEGORIES '*********************************************** 'Don't show if we're on second page (unless config setting overides) If numRecordPosition = 1 or GetAppVar("showsubcategoriesonallpages") = "y" then '----------------------------------------------- 'PRODTYPE (CATEGORY) QUERY 'Pull out all the sub-categories in this 'category. Order prodtypes by strCategoryOrderBy 'which was set on the buildpage.asp '----------------------------------------------- If CAT_ID = 0 then 'We need to pull out all categories that either are parents of 0 'OR aren't linked to categories at all strQuery = "SELECT * FROM tblCactuShop" & TABLE_PREFIX & "Categories c LEFT OUTER JOIN tblCactuShop" & TABLE_PREFIX & "CategoryHierachy ch ON c.CAT_ID = ch.CH_ChildID WHERE (ch.CH_ParentID = " & CAT_ID & " OR ch.CH_ParentID IS NULL) AND CAT_Name" & numLanguageID & " <> '' AND CAT_Live = 'y' AND CAT_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") ORDER BY " & strCategoryOrderBy Else 'Normal category - pull out categories that have this as a parent strQuery = "SELECT * FROM tblCactuShop" & TABLE_PREFIX & "Categories c LEFT OUTER JOIN tblCactuShop" & TABLE_PREFIX & "CategoryHierachy ch ON c.CAT_ID = ch.CH_ChildID WHERE ch.CH_ParentID = " & CAT_ID & " AND CAT_Name" & numLanguageID & " <> '' AND CAT_Live = 'y' AND CAT_CustomerGroupID IN (0," & NumSafe(DB_CG_ID) & ") ORDER BY " & strCategoryOrderBy End If Call ExecuteRS(strQuery, objRecordSet2) numCatRecordCount = objRecordSet2.recordcount If numCatRecordCount > 0 then Select Case CAT_SubCatDisplayType Case "l": strStyle = "subcategories_link" Case "s": strStyle = "subcategories_shortened" Case "n": strStyle = "subcategories_normal" Case "e": strStyle = "subcategories_extended" End Select '----------------------------------------------------- 'SHOW SUB CATEGORIES 'For multi-column categories, we need to get the 'number of columns and calculate the column width '----------------------------------------------------- If Not CAT_ID = 0 then 'We're in a categories, so we're showing sub categories %>
<% WriteString("ContentText_SubCategories") %>
<% end if %>
<% 'Build up the the parent IDs and names for linking. We get this 'from the trail and then add on the current category (if we're in one) Set objSubCatLinks = New DynamicLinks If objTrail.Count = 0 then Redim aryParentNames(-1) strParentIDs = "" Else strParentIDs = IIf(objTrail.Parents = "", "", objTrail.Parents & ",") & CAT_ID Redim aryParentNames(objTrail.Count - 2) For i = 1 to objTrail.Count - 1 aryParentNames(i-1) = objTrail.ItemName(i) Next aryParentNames(ubound(aryParentNames)) = CAT_Name End If numCatRecordPosition = 0 do while not objRecordSet2.EOF 'Increment the recordcount numCatRecordPosition = numCatRecordPosition + 1 'Get out useful information numSubCatID = objRecordSet2("CAT_ID") strSubCatName = objRecordSet2("CAT_Name" & CInt(numLanguageID)) strSubCatDesc = objRecordSet2("CAT_Desc" & CInt(numLanguageID)) strSubCatImageHTML = "" 'Convert description breaks if required If GetAppVar("convertdescbreaks") = "y" then strSubCatDesc = replace(strSubCatDesc, vbcrlf, "
") end if 'Set link - if we're viewing root categories, then page history should come from cat strURL = objSubCatLinks.GetCategoryLink(numSubCatID, strSubCatName, Split(strParentIDs, ","), aryParentNames, 1) strSubCatLink = "" 'Find image (only do this if required) If CAT_SubCatDisplayType = "s" or CAT_SubCatDisplayType = "e" then strFileName = GetFileLocation(strCategoryPath, numSubCatID, aryFileTypes, objFileSystem) If Not strFileName = "" Then strSubCatImageHTML = "" End If 'Display div wrap response.Write vbcrlf & "
" & vbcrlf response.Write "" & strSubCatLink & strSubCatName & "" & vbcrlf if CAT_SubCatDisplayType <> "l" then If CAT_SubCatDisplayType = "s" OR CAT_SubCatDisplayType = "e" and strSubCatImageHTML <> "" then response.Write strSubCatLink & strSubCatImageHTML & "" & vbcrlf end if response.write strSubCatDesc & vbcrlf end if objRecordSet2.MoveNext 'If we're at the end of the line, close the line tag response.Write "
" & vbcrlf loop %>
<% end if '// got subcategories objRecordSet2.Close end if '// show subcategories '*********************************************** 'LIST PRODUCTS '*********************************************** If not objRecordSet.EOF then P_OrderVersionsBy = objRecordSet("P_OrderVersionsBy") If CAT_ProductDisplayType = "s" then numProdsPerPage = GetAppVar("shortformatpagesize") else numProdsPerPage = GetAppVar("prodtypepagesize") end if %>
<% WriteString("ContentText_Products") %>
<% Call ShowProducts(objRecordSet, objRecordSet2, numProdsPerPage, CAT_ProductDisplayType, "cat", aryKeywords, numRecordPosition, objTrail) %> <% end if '// got records objRecordSet.Close if strPageLinks <> "" then %> <% end if %>
<% end if '// blnNoShow Set objFileSystem = Nothing '----------------------------------------------- 'WRITE LAST HALF OF PAGE HTML '----------------------------------------------- response.write(aryPageTemplate(1)) '----------------------------------------------- 'CLOSE DATA CONNECTIONS '----------------------------------------------- Set objRecordSetOptions = nothing Call EndPage() %>