Plumtree EDK (Enterprise Web Development Kit) 5.4.0 |

# Plumtree.Remote.PRC.Content.Item Namespace

Provides interfaces for creating, modifying, managing, and retrieving content items (See Content Item Example). This complete command-line sample includes major content item functionality, folder retrieval, Data Entry Template creation and property value updates.

Also see content item documentation for details and code samples on how to create, check-out, check-in, preview, and publish a content item.

Refer to the Administrator Guide for Content Server for additional details on Content Item functionality, or see Plumtree Developer Center for developer discussions and additional documentation.

Note: Content item names cannot be an empty string, cannot be longer than 255 characters and are case-insensitive.

A content item will be automatically deleted if the underlying Data Entry Template has been deleted.

The steps below describe common interactions between different Content Server objects.
1. Create a Data Entry Template.
2. Add one or more Content Server properties to the Data Entry Template and store the template.
3. Create a Presentation Template for the Data Entry Template.
4. Attach the Presentation Template to the Data Entry Template and store the Data Entry Template.
5. Create one or more content items using the Data Entry Template.
6. Set values for properties on the content item and check-in the content item.
7. Preview and publish the content item.
Note: One or more content items can be created using the same Data Entry Template; however, only one Presentation Template can be attached to a Data Entry Template.

Since EDK 5.2

Namespace hierarchy

### Interfaces

Interface | Description
--- | ---
IContentItem | An `IContentItem` represents a content item. It manages property value modification and retrieval, and encapulates a content item's meta-data. To update property values for a new content item use `SetPropertyValue` for the various property types and then persist the values with `IContentItemManager.CheckInItem`. To update property values for an existing content item first check out the item with `IContentItemManager.CheckOutItem` then modify property values with `Get/SetPropertyValue` and then finally persist the modifications with `IContentItemManager.CheckInItem`. For information about the conditions that make a content item searchable in the Search Server, refer to the documentation in IPresentationTemplate.Searchable. Note: To use any file upload/download functionality for setting/retreving a file or image property value, WSE 2.0 (http://msdn.microsoft.com/webservices/building/wse/) must be installed. The following example code determines what types of properties exist on a content item and how to modify their values:
    //To modify property values on an existing item, first check-out the item.
    itemManager.CheckOutItem(contentItem);

    //Retrieve all the properties on the content item
    IBaseProperty[] allProps = contentItem.GetAllProperties();

    for (int i = 0; i < allProps.Length; i++)
    {
      //Test if the property a text block property
      if (allProps[i] is ITextBlockProperty)
      {
          String oldValue = "";
          if (contentItem.HasPropertyValue(allProps[i]))
          {
            //Retrieve the old text block value if it has been set previously
            oldValue = contentItem.GetTextBlockPropertyValue(allProps[i]);
           }
           //Set the new value
           contentItem.SetTextBlockPropertyValue(allProps[i], "Updated Value: " + oldValue);
      }
      //Test if the property is an integer property
      else if (allProps[i] is IIntegerProperty)
      {
           int oldValue = 0;
           if (contentItem.HasPropertyValue(allProps[i]))
           {
              oldValue = contentItem.GetIntegerPropertyValue(allProps[i]);
           }
           contentItem.SetIntegerPropertyValue(allProps[i], 100 + oldValue);

            //Test for rest of the property types...
      }
    }

    //Finally, check-in the item to persist the updated values
    itemManager.CheckInItem(contentItem, "Check In Comment");
Note: A content item will be automatically deleted if the underlying Data Entry Template has been deleted. A content item can be indexed and made searchable, if it 1) is published, and 2) at publish time: - has the attached Presentation Template's `Searchable` set to `true`, and - has a portlet associated with the item. A portlet can be associated with a content item directly or indirectly: 1) Directly - Associate a portlet with a content item by setting the portlet ID on the item. The content item and the portlet thus become a Portlet Item. 2) Indirectly - Associate a portlet to one of the item's containing folders by adding the portlet ID to the folder. The folder must contain either a publishable Presentation Template or a content item that has already been associated to the same portlet. The folder can be either the folder containing the item, or any parent folder of that containing folder. Refer to the Administrator Guide for Content Server for additional details on content item and portlet association.
IContentItemManager | `IContentItemManager` is an interface for managing `IContentItem` instances. It handles content item creation, removal, retrieval, check-in, check-out, and publishing. To retrieve or update property values of an existing content item call `CheckOutItem` to check-out the item then `IContentItem.Get/SetPropertyValue` to modify the property values. When you are finished use `IContentItemManager.CheckInItem` to check-in the item and persist the changes. For information about the conditions that make a content item searchable in the Search Server, refer to IPresentationTemplate.`Searchable`. Refer to the Administrator Guide for Content Server for additional details on Content Item functionality. The following example demonstrates creating and publishing a content item.
    // Create a property to use in the content item
    ITextLineProperty textLineProperty = propertyManager.CreateTextLineProperty("TextLineProperty", "A line of text.");
    String templateText = "TextLineProperty=<pcs:value expr=\"TextLineProperty\">unset</pcs:value>\n";
    IPresentationTemplate presentationTemplate = presentationTemplateManager.CreatePresentationTemplate(containingFolder, "PresentationTemplate", templateText);
    presentationTemplate.Store();

    // Create Presentation Template text that uses the property
    IDataEntryTemplate dataEntryTemplate = dataEntryTemplateManager.CreateDataEntryTemplate(containingFolder, "DataEntryTemplate");
    dataEntryTemplate.AddProperty(textLineProperty);
    dataEntryTemplate.AttachPresentationTemplate(presentationTemplate);
    dataEntryTemplate.Store();

    // Create a content item and set a value for the property
    IContentItem contentItem = contentItemManager.CreateContentItem(containingFolder, "ContentItem", dataEntryTemplate);
    contentItem.SetTextLinePropertyValue(textLineProperty, "This is the string value that will appear in the published content item.");
    contentItemManager.CheckInItem(contentItem, "Initial checkin.");

    // Publish the content item
    contentItemManager.PublishContentItem(contentItem);
    // Use contentItem.PublishURL to access the published item