Ektron CMS400.NET API Documentation
|
Loads all of the metadata for the given content.
public CustomAttributeList GetContentMetadataList(Long ContentId);
Public Function GetContentMetadataList(ByVal ContentId As Long) As CustomAttributeList
Parameters |
Description |
ContentId |
The contents ID. |
Ektron.Cms.CustomAttributeList
The following example shows how to create a Web page from which all metadata for a specific content ID can be retrieved. This example uses some standard drag and drop controls and a small section of VB code utilizing the GetContentMetadataList(ByVal ContentId as Long) method. This method uses the InternalAdmin to retrieve the metadata for the content ID. 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="Label1" runat="server" Text="Content ID: "></asp:Label> 2. Add a text box to enter the content's ID. <asp:TextBox ID="txtContentId" runat="server" Width="63px"></asp:TextBox> 3. From the Validation control menu, add a RequiredFieldValidator control. This validates that something appears in the Content ID box. <asp:RequiredFieldValidator ID="rfvContentId" runat="server" ControlToValidate="txtContentId" ErrorMessage="Please enter content ID"></asp:RequiredFieldValidator> 4. Add two breaks for spacing purposes. <br /><br /> 5. Add a button to get the metadata. We will set the button click event in the code behind. <asp:Button ID="btnGetMetaData" runat="server" Text="Get MetaData" Width="91px" /> 6. Add two more breaks for spacing purposes. <br /><br /> 7. Add a label to display to display the metadata information. <asp:Label ID="lblResult" runat="server" Width="604px" Height="113px"></asp:Label>
Add the following information to the code behind of your aspx.vb page.
Protected Sub btnGetMetaData_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGetMetaData.Click
Dim metaDataApi As New Ektron.Cms.API.Metadata Dim metaDataList As New Ektron.Cms.CustomAttributeList Dim metaItem As New Ektron.Cms.CustomAttribute
If Not IsNumeric(txtContentId.Text) Then lblResult.Text = "Invalid Content ID" Exit Sub End If
Try metaDataList = metaDataApi.GetContentMetadataList(CInt(txtContentId.Text))
If metaDataList.AttributeList.Length > 0 Then lblResult.Text = "<table> <th>Metaname</th> <th align=""left"">Value</th> "
For Each metaItem In metaDataList.AttributeList If metaItem.Value.ToString().Length > 0 Then lblResult.Text &= "<tr>" lblResult.Text &= "<td>" & metaItem.Name & "</td>" lblResult.Text &= "<td>" & metaItem.Value & "</td>" lblResult.Text &= "</tr>" End If Next lblResult.Text &= "</table>"
Else lblResult.Text = "No metadata definitions found" Exit Sub End If
Catch ex As Exception lblResult.Text = ex.Message End Try End Sub
Copyright (c) 2008. All rights reserved.
|
What do you think about this topic? Send feedback!
|