You are here: Ektron Namespace > .NET Assemblies > Ektron.Cms.API Namespace > Classes > SiteMap Class > SiteMap Methods > GetWebsiteMap
Ektron CMS400.NET API Documentation
ContentsIndexHome
PreviousUpNext
SiteMap.GetWebsiteMap Method

Creates the site map from folder breadcrumb.

C#
public WebsiteMap GetWebsiteMap(Optional ByVal Long folderId, Optional ByVal Boolean getSameLevelNodes);
Visual Basic
Public Function GetWebsiteMap(Optional ByVal folderId As Long = 0, Optional ByVal getSameLevelNodes As Boolean = False) As WebsiteMap
Parameters 
Description 
folderId 
Build the web sitemap from the folder specified. 
getSameLevelNodes 
Do you want to retrieve all nodes at the same level as the one you specify?
True = include all sites at the same level as the folderId property.
False = Do not include the same level nodes.  

The following example shows how to create a Web page that displays the site map for a given folder. This example uses some standard drag and drop controls and a small section of VB code utilizing the GetWebsiteMap method. This method uses the InternalAdmin to access and return the site map information. In the first section, we will deal with the standard drag and drop controls. In the second, we'll deal with the code behind. 

 

  1. Between the form tags, add the following label:
       <asp:Label ID="Label6" runat="server" Text="Folder ID:" Width="66px"></asp:Label>
  2. Add text box where the folder ID can be entered.
       <asp:TextBox ID="txtFolderId" runat="server" Width="55px"></asp:TextBox> 
  3. From the Validation control menu, add a RequiredFieldValidator control. This validates that something appears in the Folder ID box.
       <asp:RequiredFieldValidator ID="rfvId" runat="server" ControlToValidate="txtFolderId"
              ErrorMessage="Please enter folder ID" Width="179px"></asp:RequiredFieldValidator>
  4. Add two breaks for spacing purposes.
       <br /><br />
  5. Add a button to submit the folder ID and retrieve the site map information. We will set the button click event in the code behind.
       <asp:Button ID="btnGet" runat="server" Text="Get site map" Width="91px" />
  6. Add two more breaks for spacing purposes.
       <br /><br />
  7. Add a label to display the site map.
       <asp:Label ID="lblResult" runat="server" Width="502px" Height="100px"></asp:Label>

 

Add the following information to the code behind of your aspx.vb page.

  1. Add a button click event.

       Protected Sub btnGet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGet.Click

  1. Check to make sure the folder ID is numeric.

            If Not IsNumeric(txtFolderId.Text) Then
                lblResult.Text = "Invalid Folder ID"
                Exit Sub
            End If

  1. Create an object for the site map API.

            Dim sitemapApi As New Ektron.Cms.API.SiteMap 

  1. Create an object for the map data.

            Dim mapData As Ektron.Cms.Common.WebsiteMap

  1. Create a Try/Catch around the GetWebsiteMap method. This allows you to catch any exceptions and helps when debugging.

            Try
                mapData = sitemapApi.GetWebsiteMap(CInt(txtFolderId.Text), False)

  1. Check to make sure child nodes are returned. If child nodes are returned, display the information.

               If (Not mapData.childrenNodes Is Nothing) Then
                   lblResult.Text = sitemapApi.RenderWebsiteMap(mapData, "")

  1. If no child nodes are returned, display a message.

               Else
                   lblResult.Text = "No breadcrumb path found"
               End If

  1. Display a message if there is an error.

              Catch ex As Exception
                 lblResult.Text = ex.Message
              End Try
       End Sub
Created with a commercial version of Doc-O-Matic. In order to make this message disappear you need to register this software. If you have problems registering this software please contact us at [email protected].
Copyright (c) 2008. All rights reserved.
What do you think about this topic? Send feedback!