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

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.  

C#
public LibraryData[] GetAllChildLibItems(String Type, Long ParentId, String OrderBy, int currentPageNum, int pageSize, ref int totalPages);
Visual Basic
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:
  • images
  • files
  • hyperlinks
  • quicklinks
  • forms
 
ParentId 
The folder's ID. 
OrderBy 
The order to load the library items. You can pass:
  • librarytitle
  • libraryid
  • libraryfilename
  • date
 
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.

  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 library API.

             Dim libraryApi As New Ektron.Cms.API.Library

  1. Create an array to contain the library data.

             Dim data As Ektron.Cms.LibraryData()

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

             Try
                 data = libraryApi.GetAllChildLibItems("images", CInt(txtFolderId.Text), "", 0, 0, 0)

  1. Check to make sure the library has images for the folder.

                 If (Not data Is Nothing) AndAlso (data.Length > 0) Then

  1. If so, create an object for each library item.

                     Dim item As Ektron.Cms.LibraryData

  1. Create an empty string.

                     Dim str As String = ""

  1. Iterate through each item and display the image with the image title as the alt text.

                      For Each item In data
                          str &= "<img src=""" & item.FileName & """ alt=""" & item.Title & """/>" & "<br/>" & "<br/>"
                          lblResult.Text = str
                      Next

  1. If the library contains no images for the folder, display a message.

                  Else
                      lblResult.Text = "No images 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!