<%@ Language=VBScript %> <% '************************************************************************* ' DO NOT MODIFY THIS SCRIPT IF YOU WANT UPDATES TO WORK! ' Function : Category Maintenance ' Product : CandyPress Store Administration ' Version : 2.5 ' Modified : February 2004 ' Copyright: Copyright (C) 2004 CandyPress.Com ' See "license.txt" for this product for details regarding ' licensing, usage, disclaimers, distribution and general ' copyright requirements. If you don't have a copy of this ' file, you may request one at webmaster@candypress.com '************************************************************************* Option explicit Response.Buffer = true const adminLevel = 1 %> <% 'Database dim mySQL, cn, rs 'Categories dim idCategory dim categoryDesc dim idParentCategory dim categoryFeatured dim categoryHTML dim categoryHTMLLong dim sortOrder 'Work Fields dim action dim parentCategoryDesc dim i dim catArray, catArray2 '************************************************************************* 'Open Database Connection call openDB() 'Store Configuration if loadConfig() = false then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Could not load Store Configuration settings.") end if %>

Category Maintenance

<% 'Get action action = trim(Request.QueryString("action")) if len(action) = 0 then action = trim(Request.Form("action")) end if action = lCase(action) if action <> "edit" and action <> "del" and action <> "add" then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Invalid Action Indicator.") end if 'Get idCategory if action = "edit" or action = "del" then idCategory = trim(Request.QueryString("recId")) if len(idCategory) = 0 then idCategory = trim(Request.Form("recId")) end if if idCategory = "" or not isNumeric(idCategory) then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Invalid Record ID.") end if end if 'Get Record if action = "edit" or action = "del" then mySQL="SELECT a.idCategory, a.categoryDesc, " _ & " a.idParentCategory, a.categoryFeatured, " _ & " a.categoryHTML,a.sortOrder,a.categoryHTMLLong, " _ & " (SELECT b.categoryDesc " _ & " FROM categories b " _ & " WHERE b.idCategory = a.idParentCategory) " _ & " AS ParentCategoryDesc " _ & "FROM categories a " _ & "WHERE a.idCategory = " & idCategory set rs = openRSexecute(mySQL) if rs.eof then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Invalid Record ID.") else categoryHTMLLong = trim(rs("categoryHTMLLong")) categoryDesc = trim(rs("categoryDesc")) idParentCategory = rs("idParentCategory") categoryFeatured = rs("categoryFeatured") ParentCategoryDesc = rs("ParentCategoryDesc") categoryHTML = trim(rs("categoryHTML")) sortOrder = rs("sortOrder") end if call closeRS(rs) end if 'Edit if action = "edit" then %> Edit Category  <%call maintNavLinks()%>

Category Description Parent Category
<% if idParentCategory = 0 then %> <ROOT> <% else %> <% end if %>
Featured? Sort Order
Category HTML (Short)
">
Category HTML (Long)
<% end if 'Add if action = "add" then %> Add Category  <%call maintNavLinks()%>

Category Description Parent Category
Featured? Sort Order
Category HTML (Short)
Category HTML (Long)
<% end if 'Delete if action = "del" then %> Delete Category  <%call maintNavLinks()%>

Category Description Parent Category Featured? Sort Order
<%=CategoryDesc%> <%=ParentCategoryDesc%> <%=CategoryFeatured%> <%=emptyString(SortOrder,"N/A")%>
<% end if if action = "edit" or action = "add" then %>
Help and Instructions :
Category Description - Mandatory. A name for the category.

Parent Category - Mandatory. The parent category to which a sub-category is linked. A sub-category can also act as the parent category for another sub-category, thereby creating a nested category structure than can be many levels deep.

Featured? - Mandatory. This is used to determine if the category will be dynamically displayed in the navigation bars. If you will be creating your own navigation menus, this setting is not really important.

Sort Order - Optional. Numeric value that can be used to order the Categories when it's displayed to the customer. If no value is supplied, the Categories will be sorted by their descriptions.

Category HTML (Short) - Optional. The contents of this field will be inserted right before the Category Description in the Category Tree view. HTML is allowed, which means you can use an IMG tag to display images, or you can display bold text. You can also use an A tag to create a link to another dicument. There is a 255 character restriction on this field. Some examples are :

1. <IMG SRC="../CatImg/image.gif">
2. <b>BOLD TEXT</b>
3. Plain Text
4. <A href=instructions.htm>Instructions</A>
Category HTML (Long) - Optional. The contents of this field will be displayed on top of the page in the Product List view. You can use plain text or HTML. There is no limit to the number of characters in this field.

<% end if call closedb() %> <% '********************************************************************* 'Create Navigation Links '********************************************************************* sub maintNavLinks() %> [ List Categories | >Edit | Add | >Delete ] <% end sub %>