Ektron CMS400.NET API Documentation
|
Loads all of the library items by type. Using the OrderBy parameter allows you to sort the library items. The currentPageNum, pageSize and totalPages parameters are used with paging. Setting currentPageNum and pageSize to zero causes the API To retrieve all items on a single page.
Note: The caller of API must actually call the API with the correct page number to implement paging. The API does not provide any inherent UI for paging purposes.
public LibraryData[] GetAllChildLibItems(String Type, Long ParentId, String OrderBy, int currentPageNum, int pageSize, ref int totalPages);
Public Function GetAllChildLibItems(ByVal Type As String, ByVal ParentId As Long, ByVal OrderBy As String, ByVal currentPageNum As Integer, ByVal pageSize As Integer, ByRef totalPages As Integer) As LibraryData()
Parameters |
Description |
Type |
The library item's type. (Required) Use one of the following:
|
ParentId |
The folder's ID. |
OrderBy |
The order to load the library items. You can pass:
|
currentPageNum |
The current page number to display. |
pageSize |
The page size set by the caller of the API. |
totalPages |
The total number of pages required to display all of the items. |
Ektron.Cms.LibraryData()
The following example shows how to create a Web page that displays a graphical list of all images stored in the library for a specific folder in the Workarea. This example uses some standard drag and drop controls and a small section of VB code utilizing the GetAllChildLibItems method. This method uses the InternalAdmin to retrieve the images. 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 Label with the following information. <asp:Label ID="Label6" runat="server" Text="Folder ID:" Width="76px"></asp:Label> 2. Add a text box for the Folder ID. <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 a folder ID"></asp:RequiredFieldValidator> 4. Add a couple of breaks for spacing purposes. <br /><br /> 5. Add a submit button. We will set the button click event in the code behind. <asp:Button ID="btnGet" runat="server" Text="Get Images" Width="74px" /> 6. Add two more breaks for spacing purposes. <br /><br /> 7. Add a label to display the list of images. <asp:Label ID="lblResult" runat="server"></asp:Label>
Add the following information to the code behind of your aspx.vb page.
Protected Sub btnGet_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnGet.Click
If Not IsNumeric(txtFolderId.Text) Then lblResult.Text = "Invalid Folder ID" Exit Sub End If
Dim libraryApi As New Ektron.Cms.API.Library
Dim data As Ektron.Cms.LibraryData()
Try data = libraryApi.GetAllChildLibItems("images", CInt(txtFolderId.Text), "", 0, 0, 0)
If (Not data Is Nothing) AndAlso (data.Length > 0) Then
Dim item As Ektron.Cms.LibraryData
Dim str As String = ""
For Each item In data str &= "<img src=""" & item.FileName & """ alt=""" & item.Title & """/>" & "<br/>" & "<br/>" lblResult.Text = str Next
Else lblResult.Text = "No images found" 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!
|