Dynamic areas in Ad Hoc Correspondence are defined in Composition Center. Each resource in a document definition can be Ad Hoc enabled, and thereby defined as a dynamic area in Ad Hoc Correspondence. The Ad Hoc Correspondence user can then change the content of the dynamic area (edit content, add content, replace content or delete content). To make this work for a Template Engine Process, the Template Engine template must be adapted to Ad Hoc Correspondence.
Note that if the Template Engine template is correctly adapted to Ad Hoc Correspondence, and if a resource is not Ad Hoc enabled in Composition Center, the resource will be displayed in Ad Hoc Correspondence as "read only".
To enable dynamic areas for resources in the Template Engine template, the resources must be referenced within
<div> elements, and the
<div> elements must have the
data-relation-id attribute containing the URI to the resource. For example:
The <div> tag tells the Ad Hoc Correspondence application to draw bounding boxes around the resource and to add the context menu for Add, Edit, Replace and Delete. The value of the
data-relation-id attribute is defined by the resource name and the
propertyValue() function. This attribute value is resolved to the correct resource URI in the Template Engine output, for example:
If you use hardcoded references to resources, e.g. $docdef.Section1.Text1, the only modification the AdHoc Correspondence user can do is to edit the text. If he deletes the text or adds a new text to this dynamic area in Ad Hoc Correspondence the output will fail.
Instead of using hardcoded references you can use dynamic references, i.e. loop over the resources in a section. By doing this you do not have to know the names of the resources, how many resources there are in a section, etc. The Ad Hoc Correspondence user will also be able to add, delete and replace content.
In this example, the #foreach directive is used to loop over all resources in the section Section1.