Code to Change How a Category is Displayed

Category names must be unique within a catalog. This prevents using multiple categories with the same category name in a single catalog. For example, if you have a catalog containing a category for men's clothing and a category for women's clothing, then you cannot have a child category named Shoes in both those categories.

All categories in Commerce Server 2002 have a built-in multilingual DisplayName property that does not have to be unique. The DisplayName property defaults to the value of the CategoryName property of the category.

The following example is typical of code in the Commerce Server Retail Solution Site. It demonstrates the simple change needed to use display names:

' 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 hyper 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

Copyright © 2005 Microsoft Corporation.
All rights reserved.