%option explicit%>
<%response.buffer=true%>
<%ShopOpenDatabase dbc%>
<%
'*********************************************************************************
' 7.00
' 1 Dec 2009
' Display shop categories
' displays a list of categories from Shopping Database
'*********************************************************************************
dim colcount, ycatmaxcolumns, totalcolumncount
dim strcatImage
dim lngcatid
dim strcathide
dim Mylink
dim highercategoryid
dim strcatmemo, strcatextra, strcatproductTemplate
SetSess "currenturl", "shopdisplaycategories.asp"
highercategoryid = cleanchars(request("id"))
if not isnumeric(highercategoryid) then
highercategoryid = ""
end if
'800 - Enhanced SEO
redirect_displaycategories_check highercategoryid
'700 - SEO
getseohighercategoryid highercategoryid
setsess "seohighercategoryid", ""
if highercategoryid = "" then
highercategoryid = 0
end if
'700 - 2010.04.15 - category box enhancement
SetSess "cat_id", highercategoryid
InitializeSystem
CheckDatabaseOpen dbc
ycatmaxcolumns = clng(GetConfig("xcatmaxcolumns"))
SetupdynamicCategory dbc, highercategoryid
ShopPageHeader
CategoryHeader
ShowCategories
ShopPageTrailer
ShopCloseDatabase dbc
session("seocategoryname") = ""
'Show Categories
sub ShowCategories()
dim rs
dim categoryid
colcount = 0
totalcolumncount = 0
SQL = "Select "& session("get_categories_allstr") &" from categories "
sql = Sql & " where highercategoryid=" & highercategoryid
if GetConfig("xproductmatch") = "Yes" then
'6.50 - enhanced product matching
sql = sql & " and "
generateProductmatchsqlsubscat sql
end if
'700 - Customer Groups - Matching Custormer match
sql = sql & GenerateCustomerMatchSQL ("customermatch","excustomermatch","categories.loggedin","and")
Handle_SelectCategoriesByLanguage
sql = sql & " order by " & GetConfig("xsortcategories")
'700 - 2010.08.12 - Enhancement: To speed up display categories if using sql 2005 and above
ShopOpenRecordSet sql, rs, 9999, 1
while not rs.eof
categoryid = rs("categoryid")
strcatmemo = TranslateLanguage(dbc, "categories", "catmemo", "categoryid", categoryid, rs("catmemo"))
strcatextra = rs("catextra")
lngcatid = rs("categoryid")
strcategory = rs("catdescription")
strsubcategory = rs("hassubcategory")
strcatimage = rs("catimage")
strcathide = rs("cathide")
strcatproductTemplate = rs("catproductTemplate")
if isnull(strcatimage) then
strcatimage = ""
end if
strcatimage = replace(strcatimage, " ", "%20")
if isnull(strsubcategory) then
strsubcategory = ""
end if
if isnull(strcategory) then
'6.09 - change to use lang variable
'strcathide = trim(GetLang("langcommonyes"))
'VP-ASP 6.50.4 Bugs Fix - category hide issue
strcathide = ""
else
'800 - 2015.10.20 - Category: Category name should not have any HTML tag
strcategory =CMSRemoveHTML(TranslateLanguage(dbc, "categories", "catdescription", "categoryid", categoryid, strcategory))
end if
if isnull(strcatextra) then
strcatextra = ""
end if
if isnull(strcatmemo) then
strcatmemo = ""
end if
if GetConfig("xcategoryuseTemplate") = "Yes" then
FormatCategoryTemplate lngcatid, strcategory, rs
else
FormatCategory lngcatid, strcategory, rs
end if
rs.MoveNext
wend
if colcount> 0 then
FillRemainingColumns
end if
htmlwrite ""
htmlwrite ""
CloseRecordSet rs
dim xcatdesclimit
xcatdesclimit = getconfig("xcatdesclimit")
if trim(xcatdesclimit) = "" then xcatdesclimit = 38
if not isnumeric(xcatdesclimit) then xcatdesclimit = 38
%>
<%
end sub
'Used only if Template formatting is used
sub FormatCategoryTemplate(lngcatid, strcategory, objrs)
dim Template, rc
'7.00 - to use unique category templates
Template = ""
'if GetConfig("xcategoryproductTemplates") = "No" then
' template = objrs("catproductTemplate")
'end if
if Template = "" or isnull(template) then
Template = GetConfig("xcategorydisplayTemplate")
if Template = "" then
SError = GetLang("LangExdNoTemplate")
ShopError SError
end if
end if
'VP-ASP 6.50.4 Bugs Fix - category hide issue
if strcathide <> "" or isnull(strcathide) = false then
exit sub
end if
if colcount = 0 then
htmlwrite "
"
end if
'700 - 2010.06.18 - Bug Fix: xmaxcartcolumns issue at shopdisplaycategories.asp with some country using comma
'800 - 2015.05.20 - Bug Fix: xcatmaxcolumns is not working properly
dim screenvalue
if isnull(yCatMaxColumns) then yCatMaxColumns = 3
if trim(yCatMaxColumns) = "" then yCatMaxColumns = 3
if not isnumeric(yCatMaxColumns) then yCatMaxColumns = 3
screenvalue = 12 / cdbl(yCatMaxColumns)
htmlwrite ""
ShopTemplateWrite Template, objRs, rc
'800 - 2015.05.20 - Bug Fix: xcatmaxcolumns is not working properly
htmlwrite "
"
colcount = colcount + 1
totalcolumncount = totalcolumncount + 1
if colcount>= yCatMaxColumns then
htmlwrite "
"
colcount = 0
end if
end sub
'writes out header
sub CategoryHeader
dim header
if highercategoryid<>0 then
GenerateCategoryLinks header
else
'6.09 - added breadcrumb / 6.50 - added config option to turn breadcrumb on/off
if GetConfig("xbreadcrumbs") = "Yes" then
htmlwrite ""
end if
htmlwrite ""
'800 - 2015.05.10 - Bug Fix: Convert main pages from
to for SEO Bing
htmlwrite "
" & GetLang("LangCat01") & "
"
end if
'6.50 - show category file/image if displaying sub-categories
if highercategoryid > "" then
ShowCategoryImage
end if
htmlwrite ""
end sub
'formats 1 category record
sub FormatCategory (id, name, rs)
'6.50.4 Bugs Fix - category hide issue
if strcathide <> "" or isnull(strcathide) = false then
exit sub
end if
if colcount = 0 then
htmlwrite "
"
end if
htmlwrite ""
dim mylink
if trim(strSubcategory) = "" then
mylink = "" & name & ""
else
mylink = "" & name & ""
end if
genseocategoryproductlink_v9 mylink,id,name,name,rs,strSubcategory,"Yes"
if trim(strSubcategory) = "" then
htmlwrite mylink
else
htmlwrite mylink
if GetConfig("Xcategoryproductsonly") = "No" then
htmlwrite " "
htmlwrite "" & GetLang("LangProductProduct") & ""
htmlwrite " " & GetLang("langSubcategories") & ""
end if
end if
if strCatImage<> "" then
dim returnstr
AddImage returnstr, id, name, rs
end if
if strcatmemo<>"" then
FormatCatMemo
end if
htmlwrite " | "
colcount = colcount + 1
totalcolumncount = totalcolumncount + 1
if colcount>= yCatMaxColumns then
htmlwrite "
"
colcount = 0
end if
end sub
'if category has image, format it
sub AddImage(returnstr, id, iname, rs)
dim linkname
linkname = Server.URLEncode(Iname)
'700 - SEO
dim mylink
dim tempname
tempname = Iname
if trim(strSubcategory) = "" then
mylink = "shopdisplayproducts.asp?id=" & id & "&cat=" & linkname
else
mylink = "shopdisplaycategories.asp?id=" & id & "&cat=" & linkname
end if
genseocategoryproductlink_v9 mylink,id,tempname,tempname,rs,"","No"
returnstr = "
"
end sub
sub FillRemainingColumns
if totalcolumncount< ycatmaxcolumns then
response.write ""
exit sub
end if
do while Colcount
"
colcount = colcount + 1
loop
response.write ""
end sub
sub GenerateCategoryLinks (header)
dim highercatid, cats(10), catids(10), i, mylink, categoryid
dim cathead, more, catsql, rs
dim id, name
'701 - 2011.05.18 - Bug Fix: Category name is displaying incorrectly as the title when seo dynamic activated
dim disname
cathead = ""
More = true
i = 0
highercatid = highercategoryid
do while more = true
catsql = "select "& session("get_categories_allstr") &" from categories where categoryid=" & highercatid
openrecordset_common rs
'700 - 2010.09.26 - Enhancement: Speed up front store performance
'701 - 2011.03.15 - Enhancement: Speed up store performance
'701 - 2012.02.16 - Enhancement: Better DB handling on display categories page
rs.open catsql, dbc, adOpenStatic, adLockReadOnly
if not rs.eof then
highercatid = rs("highercategoryid")
categoryid = rs("categoryid")
name = rs("catdescription")
id = rs("categoryid")
'800 - 2015.10.20 - Category: Category name should not have any HTML tag
name = CMSRemoveHTML(TranslateLanguage(dbc, "categories", "catdescription", "categoryid", categoryid, name))
'701 - 2011.05.18 - Bug Fix: Category name is displaying incorrectly as the title when seo dynamic activated
'701 - 2011.06.17 - Bug Fix: Category name is displaying incorrectly while having sub-categories
if cstr(highercategoryid) = cstr(categoryid) then disname = name
'701 - 2011.05.12 - Bug Fix: Higher category link breadcrumb is not formatted correctly if seo dynamic activated
mylink = "" & name & ""
genseocategoryproductlink_v9 mylink,rs("categoryid"),name,name,rs,"","Yes"
cats(i) = mylink
i = i + 1
if highercatid = 0 then
more = false
end if
else
more = false
end if
CloseRecordSet rs
loop
'6.09 - added home to breadcrumb
'800 - Enhanced SEO
mylink = "" & GetLang("langcommonhome") & " " & SubCatSeparator & "" & GetLang("LangCommonCategories") & ""
cats(i) = mylink
i = i + 1
for i = 0 to i -1
if cathead = "" then
cathead = cats(i)
else
cathead = cats(i) & subcatseparator & cathead
end if
next
header = cathead
SetSess "breadcrumb", cathead
'6.50 - added config option to turn breadcrumb on/off
if GetConfig("xbreadcrumbs") = "Yes" then
htmlwrite "" & header & "
"
end if
'701 - 2011.05.18 - Bug Fix: Category name is displaying incorrectly as the title when seo dynamic activated
htmlwrite ""
'800 - 2015.05.10 - Bug Fix: Convert main pages from
to for SEO Bing
htmlwrite "
" & disname & "
"
'2019.09.04 - Bug Fix: Catmemo not shown when Subcategories set to yes
ShowCategoryImage_memo highercategoryid
end sub
'800 - 2015.05.17 - Better handling on routine handle_product
sub Handle_Product (isub, value, parseRS)
select case isub
case "FORMATIMAGE"
if strCatImage<> "" then
AddImage value, lngcatid, strcategory, parseRS
end if
case "FORMATHYPERLINKS"
GenerateCatLink value, lngcatid, strcategory, parseRS
case "ADDNUMBERSUBCATS"
Handle_NumberSubCats lngcatid, "", ""
'800 - 2015.-5.14 - Better handling if xgenerateshopexdlink set to No
case "FORMATEXDLINK_DIV"
formatexdlink_v8 value, parseRS, "div"
case "FORMATEXDLINK_SEARCH"
formatexdlink_v8 value, parseRS, "searchlink"
case "FORMATEXDLINK_MOBILE_DETAIL"
formatexdlink_v8 value, parseRS, "mobiledetail"
case "FORMATEXDLINK_SIDE_DESKTOP_DETAIL"
formatexdlink_v8 value, parseRS, "sidedesktopdetail"
case "FORMATEXDLINK_SIDE_MOBILE_DETAIL"
formatexdlink_v8 value, parseRS, "sidemobiledetail"
case "FORMATEXDLINK_FRONT_DESKTOP_SEARCH"
formatexdlink_v8 value, parseRS, "frontdesktopsearch"
case "FORMATEXDLINK_FRONT_MOBILE_SEARCH"
formatexdlink_v8 value, parseRS, "frontmobiletopsearch"
case "FORMATEXDLINK"
value = formatexdlink_v9(parseRS)
case else
messagewrite "Unknown sub"
end select
end sub
sub GenerateCatLink(returnstr, id, name, rs)
'2021.07.26 - Category listings: Better handling on identify parent category
dim strSubcategory
strSubcategory = rs("hassubcategory")
if isnull(strSubcategory) then strSubcategory = ""
dim mylink
if strSubcategory = "" then
mylink = "" & name & ""
'700 - SEO
genseocategoryproductlink_v9 mylink,id,name,name,rs,strSubcategory,"Yes"
returnstr = mylink
else
mylink = "" & name & ""
'700 - SEO
genseocategoryproductlink_v9 mylink,id,name,name,rs,strSubcategory,"Yes"
returnstr = mylink
if GetConfig("Xcategoryproductsonly") = "No" then
returnstr = returnstr & "
"
genseocategoryproductlink_v9 mylink,id,name,GetLang("LangProductProduct"),rs,strSubcategory,"Yes"
returnstr = returnstr & mylink
genseocategoryproductlink_v9 mylink,id,name,GetLang("langSubcategories"),rs,strSubcategory,"Yes"
returnstr = returnstr & mylink
end if
end if
end sub
sub FormatCatMemo
if GetConfig("xcategorydisplaytext") = "Yes" then
if strcatmemo<>"" then
htmlwrite "" & strcatmemo & "
"
end if
end if
end sub
sub Handle_SelectCategoriesByLanguage
if GetConfig("xselectproductsbylanguage") = "Yes" and GetSess("language")<>"" then
sql = sql & " and (catlanguage='" & GetSess("language") & "'"
sql = sql & " or catlanguage is null)"
end if
end sub
'6.5 - show category image or file at the top of subcat display
sub ShowCategoryImage
dim ImageFileName, description, i
dim rs
dim query
imagefilename = ""
if highercategoryid = "" then exit sub
'2022.05.24 - SEO: Category listings: Alt should be assigned to image object
dim catdescription
if GetConfig("xDisplayCategoryImages") = "Yes" or GetConfig("xdisplaycategoryfiles") = "Yes" then
'2022.05.24 - SEO: Category listings: Alt should be assigned to image object
query = "select catimage,catextra,catdescription from categories where categoryid = " & highercategoryid
openrecordset_common rs
'700 - 2010.09.26 - Enhancement: Speed up front store performance
'701 - 2011.03.15 - Enhancement: Speed up store performance
'701 - 2012.02.16 - Enhancement: Better DB handling on display categories page
rs.open query, dbc, adOpenStatic, adLockReadOnly
if not rs.eof then
imagefilename = rs("catimage")
description = rs("catextra")
if isnull(imagefilename) then
imagefilename = ""
end if
if isnull(description) then
description = ""
end if
'2022.05.24 - SEO: Category listings: Alt should be assigned to image object
catdescription = rs("catdescription")
if isnull(catdescription) then
catdescription = ""
end if
end if
CloseRecordSet rs
else
exit sub
end if
if GetConfig("xDisplayCategoryImages") = "Yes" and imagefilename<>"" then
'2022.05.24 - SEO: Category listings: Alt should be assigned to image object
htmlwrite "
![]()
"
end if
'2022.07.06 - Bug Fix: Category listings: CatExtra show twice on parent category page
exit sub
if GetConfig("xdisplaycategoryfiles") = "Yes" and description <>"" then
dim readarray(500), readcount
readcount = 0
ShopReadFile description, ReadArray, readcount
if readcount = 0 then exit sub
htmlwrite "
"
for i = 0 to readcount -1
htmlwrite readarray(i) & vbcrlf
next
end if
end sub
%>