Code to Execute the ContentSelector Object

The following code shows how ContentSelector objects are typically created, used to select the content through the GetContent method, and write that content to the Web page.

The following code should be included in a subroutine of an include file. For an example of how the ContentSelector object is used in the Solution Sites, see the files banner.inc and discount.asp located at <drive>:\Inetpub\wwwroot\<Solution Site name>\template\.

<%
    ' Create a ContentSelector object.
    Set CSO = Server.CreateObject("Commerce.ContentSelector")

    ' Use the GetContent method to get some content. Use the dictionary
    ' previously created in the Global.asa file and referenced through the
    ' Application collection.
    Set Ads = CSO.GetContent(Application("CSFAdsContext"))
    ' Ads is a SimpleList containing the selected content.
    ' Write the content to the page, if any.
    For Each Ad in Ads
        Response.Write(Ad)
    Next
%>

Other, optional properties may be set on the ContentSelector object as well. These properties depend on the components in the selection pipeline and their configuration. The most common optional properties include UserProfile, NumRequested, PageGroup, and Size.

Commerce Server Solution Sites are available at https://go.microsoft.com/fwlink/?linkid=6491.

Copyright © 2005 Microsoft Corporation.
All rights reserved.