Documentation Center

Dreamweaver Templating short examples

A number of examples of how to use Dreamweaver Templates.

Display a single-value Component field

@@FieldStartMarker("Surname")@@
  @@FieldValueStartMarker()@@
    @@GetFieldValue("Surname", 0)@@
  @@FieldValueEndMarker()@@
@@FieldEndMarker()@@

Display all values of a multivalue Component field

@@FieldStartMarker("BusinessPartners")@@
  <!-- TemplateBeginRepeat Name="BusinessPartners" -->
    @@FieldValueStartMarker(TemplateRepeatIndex)@@
      @@GetFieldValue("BusinessPartners", TemplateRepeatIndex)@@
    @@FieldValueEndMarker()@@
  <!-- TemplateEndRepeat -->
@@FieldEndMarker()@@

Display a single-value Component metadata field

<!-- TemplateBeginIf cond="Metadata.EditorSurname" -->
  @@FieldStartMarker("Metadata.EditorSurname")@@
    @@FieldValueStartMarker()@@
      @@GetFieldValue("MetaData.EditorSurname", 0)@@
    @@FieldValueEndMarker()@@
  @@FieldEndMarker()@@ 
<!-- TemplateEndIf -->

Display all values of a multivalue Component metadata field

@@FieldStartMarker("Metadata.AuthorSurnames")@@
  <!-- TemplateBeginRepeat Name="Metadata.AuthorSurnames" -->
    @@FieldValueStartMarker(TemplateRepeatIndex)@@
      @@GetFieldValue("Metadata.AuthorSurnames", TemplateRepeatIndex)@@
    @@FieldValueEndMarker()@@
  <!-- TemplateEndRepeat -->
@@FieldEndMarker()@@

Display a single-value embedded Component field

<!-- TemplateBeginIf cond="Address.Street" -->
  @@FieldStartMarker("Address.Street")@@
    @@FieldValueStartMarker()@@
      @@GetFieldValue("Address.Street", 0)@@
    @@FieldValueEndMarker()@@
  @@FieldEndMarker()@@ 
<!-- TemplateEndIf -->

Display all values of an embedded multivalue Component field

In this case, one of the subfields of the embedded fields can have multiple values. For example, a customer record can have multiple phone numbers.

@@FieldStartMarker("Team.Members")@@
  <!-- TemplateBeginRepeat Name="Team.Members" -->
    @@FieldValueStartMarker(TemplateRepeatIndex)@@
      @@GetFieldValue("Team.Members", TemplateRepeatIndex)@@
    @@FieldValueEndMarker()@@
  <!-- TemplateEndRepeat -->
@@FieldEndMarker()@@

Display all values of a multivalue embedded Component field

In this case, the embedded field itself can have multiple values, each with its own set of subfields. For this example, first assume the following input XML:

<Content xmlns="uuid:8841d68e-7b1b-45cd-a6d6-7e7da5de3ef9">
	<body>
		<section>Blue section</section>
		<section>Green section</section>
	</body>
	<body>
		<section>Yellow section</section>
		<section>Red section</section>
	</body>
</Content>

To produce output for all the <section> elements, create a nested loop that uses the FieldPath variable:

@@FieldStartMarker("body")@@
  <!-- TemplateBeginRepeat name="body" -->
    @@FieldValueStartMarker(TemplateRepeatIndex)@@
      @@FieldStartMarker(Field.section)@@
        <!-- TemplateBeginRepeat name="Field.section" -->
          @@FieldValueStartMarker(TemplateRepeatIndex)@@
            <div>@@GetFieldValue(FieldPath + ".section", TemplateRepeatIndex)@@</div>
          @@FieldValueEndMarker()@@
        <!-- TemplateEndRepeat -->
      @@FieldEndMarker()@@
    @@FieldValueEndMarker@@
  <!-- TemplateEndRepeat -->
@@FieldEndMarker()@@

In this code example:

  • The outer loop iterates over the values of the outer multivalue field called body.
  • The inner loop iterates over the values of the inner multivalue field called section.
  • The Field variable in Field.section refers to the current value of the body multivalue field.
  • Within the inner loop, FieldPath refers to the specific value of body now being examined: body[0] or body[1].
  • Within the inner loop, TemplateRepeatIndex refers to the iterator of the inner loop, that is, the index number of the current value of section now being examined: 1 or 2.