Replacing RenderComponentField() calls in your templates

The RenderComponentField() method is deprecated (as of SDL Tridion 2013 SP1). If you continue to use the legacy template-based publishing model after upgrading to Tridion Sites 10, update your templates to instead call newer methods.

About this task

SDL Tridion 2013 SP1 HR1 deprecated the RenderComponentField() method at the same time it added the following methods:

  • FieldStartMarker()
  • FieldEndMarker()
  • FieldValueStartMarker()
  • FieldValueEndMarker()

The newer methods make it possible to add, remove and move embedded fields in Experience Manager.

Procedure

  1. In Adobe Dreamweaver or a text editor of your choice, open a Template Building Block that contains one or more RenderComponentField() calls.
  2. In the location of the RenderComponentField() call, write the following:
    @@FieldStartMarker(FIELDNAME)@@
    @@FieldEndMarker()@@

    where FIELDNAME is the name of the field you want to display, either the actual name enclosed in double quotes or a variable. FIELDNAME may refer to a subfield of an embedded field (for example, "Address.Street") or to a metadata field ("Metadata.Editor").

  3. If this is a multivalue field over whose values you wish to iterate, add the following inside your new code block:
    <!-- TemplateBeginRepeat Name="FIELDNAME" -->
    <!-- TemplateEndRepeat -->

    where FIELDNAME is the name of the field you want to display, enclosed in quotes, either the actual name enclosed or a variable enclosed in variable delimiters (either ${ and } or @@ and @@.

  4. Inside your current code block, enter one of the following:
    • If you are rendering a single-value field:

      @@FieldValueStartMarker()@@
        @@GetFieldValue(FIELDNAME, 0)@@
      @@FieldValueEndMarker()@@
    • If you are iterating over a multivalue field:

      @@FieldValueStartMarker(TemplateRepeatIndex)@@
        @@GetFieldValue(FIELDNAME, TemplateRepeatIndex)@@
      @@FieldValueEndMarker()@@
    • If you are rendering one specific value of a multivalue field (say, the fourth field):

      @@FieldValueStartMarker(3)@@
        @@GetFieldValue(FIELDNAME, 3)@@
      @@FieldValueEndMarker()@@

    where FIELDNAME is the name of the field you want to display, either the actual name enclosed in double quotes or a variable.

  5. Save and close your Template Building Block.
  6. In Content Manager Explorer, use the Where Used functionality to find out which Templates use this Template Building Block.
  7. Republish all Templates that use this Template Building Block.
  8. Find another Template Building Block that contains RenderComponentField() calls, and change it in the same way. Continue until all your Template Building Blocks have been updated.