The following example shows how to create a Web page from which the breadcrumb path for a given folder can be retrieved. In this This example uses some standard drag and drop controls and a small section of VB code utilizing the GetFolderBreadcrumbPath method. The GetFolderBreadcrumbPath method allows you to use a folder ID or a content's ID to retrieve the information. This method uses the InternalAdmin to retrieve the breadcrumb path. 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 a radio button list. We will populate the radio buttons in the code behind. <asp:RadioButtonList ID="rblItem" runat="server" Height="64px"></asp:RadioButtonList> 2. Add two breaks for spacing purposes. <br /><br /> 3. Add a label to show where the ID goes. <asp:Label ID="Label6" runat="server" Text="ID:" Width="76px"></asp:Label> 4. Add a text box for the ID. <asp:TextBox ID="txtId" runat="server" Width="55px"></asp:TextBox> 5. From the Validation control menu, add a RequiredFieldValidator control. This validates that something appears in the ID box. <asp:RequiredFieldValidator ID="rfvId" runat="server" ControlToValidate="txtId" ErrorMessage="Please enter a content/folder ID" Width="179px"></asp:RequiredFieldValidator> 6. Add two more breaks for spacing purposes. <br /><br /> 7. Add a button to submit the ID to be queried. We will set the button click event in the code behind. <asp:Button ID="btnGet" runat="server" Text="Get Breadcrumb" Width="105px" /> 8. Add two last breaks for spacing purposes. <br /><br /> 9. Add a label to display the breadcrumb path. <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.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack() Then rblItem.Items.Add(New ListItem("Folder", "true")) rblItem.Items.Add(New ListItem("Content", "false")) rblItem.Items(0).Selected = True End If End Sub
Protected Sub btnGet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGet.Click
If Not IsNumeric(txtId.Text) Then lblResult.Text = "Invalid content/folder ID" Exit Sub End If
Dim sitemapApi As New Ektron.Cms.API.SiteMap
Dim mapData As Ektron.Cms.Common.SitemapPath()
Try mapData = sitemapApi.GetFolderBreadcrumbPath(CInt(txtId.Text), CBool(rblItem.SelectedValue))
If (Not mapData Is Nothing) AndAlso (mapData.Length > 0) Then lblResult.Text = sitemapApi.RenderFolderBreadcrumbHtml(mapData, ">", True, "", False, "")
Else lblResult.Text = "No breadcrumb path found" End If
Catch ex As Exception lblResult.Text = ex.Message End Try End Sub