Ektron CMS400.NET API Documentation
|
Adds a new metadata type to the system.
public AddMetaDataType(ref ContentMetaData metaDataItem);
Public Sub AddMetaDataType(ByRef metaDataItem As ContentMetaData)
Parameters |
Description |
metaDataItem |
ContentMetadata object containing metadata definition details. |
The following example shows how to create a Web page from which you can add a new metadata definition. This example uses some standard drag and drop controls and a small section of VB code utilizing the AddMetaDataType(ByRef metaDataItem As ContentMetaData) method. This method uses the InternalAdmin to add the metadata definition. 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. Create a table with four rows and three columns. 2. In the first row, first column, add a label that shows where to enter the name of the metadata definition. <asp:Label ID="Label1" runat="server" Text="Name: "></asp:Label> 3. In the first row, second column, add a text box for the user to enter the metadata definition name. <asp:TextBox ID="txtMetaName" runat="server" Width="86px"></asp:TextBox> 4. In the first row, third column, add a RequiredFieldValidator control from the Validation control menu. This validates that something appears in the name box. <asp:RequiredFieldValidator ID="rfvMetaName" runat="server" ControlToValidate="txtMetaName" ErrorMessage="Please enter metadata definition name" Width="237px"></asp:RequiredFieldValidator> 5. In the second row, first column, add a label that show where to select the type. <asp:Label ID="Label4" runat="server" Text="Type:" Width="80px"></asp:Label> 6. In the second row, second column, add a drop down list for the metadata tag type. We will populate the drop down list in the code behind. <asp:DropDownList ID="ddlMetaTagType" runat="server" Width="194px"></asp:DropDownList> 7. Leave the second row, third column empty. 8. In the thrid row, first column, add a label for the Editable option. <asp:Label ID="Label7" runat="server" Text="Editable: " Width="76px"></asp:Label> 9. In the third row, second column, add a check box to decide whether a user can edit the contents of the metadata when creating or editing the metadata’s content. <asp:CheckBox ID="chkEditable" runat="server" Checked="True" /> 10. Leave the third row, third column empty. 11. In the fourth row, first column, add a label for the Display in Ektron Explorer option. <asp:Label ID="Label2" runat="server" Text="Display in Ektron Explorer" Width="119px"></asp:Label> 12. In the fourth row, second column, add a check box to decide whether the metadata definition should be displayed in Ektron Explorer. <asp:CheckBox ID="chkDisplayEE" runat="server" /> 13. Leave the fourth row, third column empty. 14. After the table, add a break and then add a button to add the Metadata Definition. <br /> <asp:Button ID="btnAdd" runat="server" Text="Add Metatype" Width="98px" /> 15. Add two breaks for spacing purposes. <br /><br /> 16. Add a results label to display whether the Metadata Definition was added and if so, its ID. <asp:Label ID="lblResult" runat="server" Width="549px" Height="25px"></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 ddlMetaTagType.Items.Add(New ListItem("Searchable Property", "100")) ddlMetaTagType.Items.Add(New ListItem("Meta Tag", "1")) ddlMetaTagType.Items.Add(New ListItem("HTML Tag", "0")) ddlMetaTagType.Items.Add(New ListItem("Collection Selector", "2")) ddlMetaTagType.Items.Add(New ListItem("Content Selector", "4")) ddlMetaTagType.Items.Add(New ListItem("File Selector", "7")) ddlMetaTagType.Items.Add(New ListItem("Hyperlink Selector", "6")) ddlMetaTagType.Items.Add(New ListItem("Image Selector", "5")) ddlMetaTagType.Items.Add(New ListItem("ListSummary Selector", "3")) End If End Sub
Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
Dim metaDataApi As New Ektron.Cms.API.Metadata Dim metaItem As New Ektron.Cms.ContentMetaData
metaItem.TypeName = txtMetaName.Text metaItem.Editable = chkEditable.Checked metaItem.MetaDisplayEE = chkDisplayEE.Checked metaItem.TagType = ddlMetaTagType.SelectedItem.Value
Try
metaDataApi.AddMetaDataType(metaItem)
If metaItem.TypeId <> 0 Then lblResult.Text = "The above metadata type definition was created in CMS400.NET with ID = " & metaItem.TypeId 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!
|