The following extended example demonstrates the power available using the Active Channel Server objects in an ASP environment to allow users to select personalized channel subscriptions.
Assume we have a page here that presents a simple form the user can use to select channels from a project. It would be nice to have the GUID values and channel Titles put in the Application collection for reference by the selector page. Here's how we could do this in the Global.Asa file. Assume a simple set of channels: one top-level, and a few in the subchannels collection.
Global.Asa
<SCRIPT LANGUAGE="VBScript" RUNAT=SERVER>
Sub Application_OnStart
Set IDispHelper = CreateObject("Push.CDFGenHelper")
IDispHelper.Load("Project1")
Set Application("Project1") = IDispHelper
' get the project out to get guids and titles
Set IDispProject = IDispHelper.Project
' add guid=title key/value pairs to a dictionary
Set ChannelTitles = CreateObject("Scripting.Dictionary")
ChannelTitles(IDispProject.Channel.GUID) = IDispProject.Channel.Title
For each channel in IDispProject.Channel.subchannels
ChannelTitles(channel.GUID) = channel.Title
Next
Set IDispProject = nothing 'remove this reference
Set Application("Channel Titles") = ChannelTitles
…
End Sub
</SCRIPT>
Now we can display the Titles and use the GUID values for an HTML form via an ASP page:
Selection.asp
<HTML>
<HEAD>
<TITLE>Select Only the Channels You Want</TITLE>
</HEAD>
<BODY>
Select The Channels You'd Like to Subscribe to:<br>
<FORM METHOD="POST" ACTION="addthem.asp">
<% For Each Key in Application("Channel Titles")
Response.write("<INPUT TYPE=\"CheckBox\" Name=\"ChanSelection\" VALUE=\""
& Key & "\">" & Application("Channel Titles")(key) & "<br>")
%>
<INPUT TYPE=SUBMIT>
</FORM>
</HTML>
Now we can use the "addthem.asp" file to add the channels to the users directory data. We then can redirect them to a CDF generating ASP page
addthem.asp
<%
' Get the directory property name used to hold the channel selections
' and style from the CDFGenHelper. Its in the Application collection
Application("Helper").GetSelectionListPropName( ListProp, StyleProp)
' Create the user's AUO
const AUOClass = "membership.userobjects"
Set IDispUserObjects=Server.CreateObject(AUOClass)
' add the guid list to the user's data
' The Form collection should have a nice array of values
' from the checkbox.
IDispUserObjects.PutEx 2, ListProp,(Request.Form("ChanSelection"))
IDispUserObjects.Put StyleProp, 0 ' inclusive list
IDispUserObjects.SetInfo
Set IDispUserObjects = nothing
Response.Clear
Response.Redirect = "generateCDF.asp"
Response.end
%>
The contents of the "generateCDF.asp" are then listed below. This script actually generates the custom CDF string for the user using their selections stored in the directory database. Way back in the first code example, the dispinterface on an instance of the CDFGenHelper class was added to the Application collection under the name "Project1". This interface is referred to when the Run method is invoked below.
generateCDF.asp
<% Set ICDFGenerator = Server.CreateObject("Push.CDFGenerator")
ICDFGenerator.Run "Project1"
%>