COM Version of BuildTopNavTable

COM Version of BuildTopNavTable

The implementation of the routine BuildTopNavTable in this section is coded in VBScript and was tested within a page template using Content Management Server 2001.

Function BuildTopNavTable() 

All of the variables are declared up front, and should be self-explanatory from their names, mostly.

    Dim ReturnString     Dim SpacerCell     Dim ChannelCell     Dim RootSubChannel     Dim SubChannelsOfRoot     Dim CurChannelMatriarch  ' Sub-channel of the root                              ' containing the current channel. 

Begin building the return string, providing an ID and class, and adding a spacer as the first cell.

    ReturnString = "<TABLE ID=""TopNavTable"" Class=""TopNav""><TR>" 

Find the current channel's matriarch channel, defined here to be the channel directly under the root channel that is an ancestor of the current channel.

    Set CurChannelMatriarch = AutoSession.ThisChannel     While Not CurChannelMatriarch.Parent.IsRoot         Set CurChannelMatriarch = CurChannelMatriarch.Parent     WEnd 

Retrieve a collection of the sub-channels of the root channel and sort them alphabetically according to their Name property.

    Set SubChannelsOfRoot = AutoSession.RootChannel.Channels     SubChannelsOfRoot.SortByName() 

Run through the collection of the root channel's sub-channels, filling in the rest of the table's row.

    For Each RootSubChannel In SubChannelsOfRoot 

Use the channel GUID property to test whether the matriarch channel has been found in this iteration. If so, build the channel cell as a bold font, non-linked display name. If not, build the channel cell as regular font, linked display name.

        If ( RootSubChannel.GUID = CurChannelMatriarch.GUID ) Then              ChannelCell = "<TD><B>" + RootSubChannel.DisplayName + "</B></TD>"         Else             ChannelCell = "<TD><A HREF=""" + _                           RootSubChannel.URL + _                           """>" + _                           RootSubChannel.DisplayName + _                           "</A></TD>"         End If Append the channel cell and another spacer cell to the return string.         ' Add the sub-channel link         ReturnString = ReturnString + ChannelCell 

Do it again until all of the sub-channels of the root channel have been processed.

    Next  ' end of For Each loop 

Append the end of the row and the end of the table to the return string, and return it.

    ReturnString = ReturnString + "</TR></TABLE>"     BuildTopNavTable = ReturnString End Function 

At the position in the page template where the table should be displayed, the following line of code could be used to send the resulting HTML back to the browser for display:

<%= BuildTopNavTable() %> 
Previous  Next

Microsoft Corporation - Microsoft. Net Server Solutions for the Enterprise
Microsoft .NET Server Solutions for the Enterprise
ISBN: 0735615691
EAN: 2147483647
Year: 2002
Pages: 483 © 2008-2017.
If you may any questions please contact us: