Plumtree EDK (Enterprise Web Development Kit) 5.4.0 |

# IDataEntryTemplate.AttachPresentationTemplate Method

Attaches an `IPresentationTemplate` to the Data Entry Template.

void AttachPresentationTemplate(
IPresentationTemplate presentationTemplate
);

#### Parameters

presentationTemplate
  The persisted Presentation Template to be attached to this Data Entry Template; cannot be `null`. The template text of the attached Presentation Template will be used to determine the layout of the published content items created with this Data Entry Template.

#### Remarks

The attachment will not be persisted until `Store` is called. A Presentation Template can only be attached to one Data Entry Template at a time, and similarily, a Data Entry Template can have only one Presentation Template attached at a time. Calling this method when the Data Entry Template already has a Presentation Template attached will result in an `InvalidOperationException`.

If this method is called with a Presentation Template that has already been attached to another Data Entry Template then an `InvalidOperationException` will be thrown when `Store` is called on the Data Entry Template.

In order to change the attached Presentation Template, call `DetachPresentationTemplate`, `Store`, then `AttachPresentationTemplate`. The Data Entry Template must be persisted after calling `DetachPresentationTemplate`, before attaching a different Presentation Template or an `InvalidOperationException` will be thrown.

This method must be called prior to `IContentItemManager.PublishContentItem`, because when an `IContentItem` of a particular `IDataEntryTemplate` is published, the layout of the published item will be determined by the template text of the `IPresentationTemplate` attached to the item's Data Entry Template.

#### Exceptions

Exception Type | Condition
--- | ---
InvalidOperationException | The Data Entry Template has already been removed, or the Data Entry Template has already been attached with a different Presentation Template, or the Presentation Template has already been removed.

#### See Also

IDataEntryTemplate Interface | Plumtree.Remote.PRC.Content.DataEntryTemplate Namespace