Code to Change How a Category is Displayed

Categories must be unique across the Product Catalog System. This prevents using the same category name in multiple catalogs. For example, if you have a catalog for men and a catalog for women, you cannot have a category in both catalogs named Shoes. You can work around this limitation by displaying a different property instead of the category name.

The following steps outline how to change how a category is displayed in your catalog:

  1. Define a property of type text and call it "DisplayName".

  2. Set the AssignToAll attribute to False.

  3. Add this property to any category definitions used, for example the Department category definition.

  4. When creating categories, the category name must still be unique, but a non-unique name can be specified for the DisplayName field.

  5. Modify the shopping site code to display the DisplayName field of a category as its name, rather than the CategoryName field.

The following example demonstrates the modifications needed. It is taken from the Browse.asp file in the Catalog sitelet in the Commerce Server 2000 SDK. The original code only needed the addition of a constant for the name of the new field and a change in one script variable: needs a simple change

' CATALOG_PROP_NAME is defined in an include file as "CategoryName".
' Create a new constant for display name field.
CATALOG_DISP_NAME = "DisplayName"
' Substitute CATALOG_DISP_NAME where appropriate.
' This loop writes out the list of available categories
' from a recordset as links to another page in the application:
<%
'...
Do While Not g_rsCategories.EOF
    ' The anchor tags produced below pass the category name to the
    ' file "browse.asp", but have been modified to show the display
    ' name as the hot text (change shown in bold text).
    %>
    <a href="browse.asp?category=
       <%= Server.URLEncode(g_rsCategories(CATALOG_PROP_NAME)) %>">
       <%= g_rsCategories(CATALOG_DISP_NAME) %>
    </a>
    <br>
    <%
    g_rsCategories.MoveNext()
Loop


All rights reserved.