Enable inline editing to enable users to modify or move existing Components on a Web page.
Before you begin
To perform this task, the following must be the case:
- You must have access to the Template Builder client application.
- You must have permission to edit the Component Template(s) that renders the Components you want to make editable inline.
You also need a thorough knowledge of SDL Tridion, including the Template Builder, Templates and Target Types. For more information about these topics, refer to the SDL Tridion suite's product documentation.
Procedure
- Access Template Builder, and open a Component Template that renders Components that you want to make editable inline and movable. Typically, you would select Component Templates that output all of the content of the Components they render. Note down the Content Manager URI of this Component Template.
- Note down which Template Building Block in this Component Template produces the package item called 'Output' (typically, this would be the Dreamweaver Template Building Block).
- Drag the Template Building Block Enable inline editing for content from the Building Blocks panel to the location directly under this output-producing Template Building Block. You can leave the parameter empty.
- Save the Component Template and repeat these steps for all other Component Templates that render Components that you want to make editable inline. Then close Template Builder.
- Now take your list of Template Building Blocks that produce output. Open each of these in an editor of your choice (if they are Dreamweaver Template Building Blocks, use Dreamweaver).
- Find the place where Component fields are rendered and ensure that the field is rendered using calls to
FieldStartMarker and FieldEndMarker, which enclose one or more calls to FieldValueStartMarker and FieldValueEndMarker, which in turn enclose the rendering of the field itself. (The sample Dreamweaver Template Building Blocks renders fields using @@Field@@).
For example, the following code outputs a single-value, editable field with a value:
@@FieldStartMarker(Fields.Address.HouseNumber)@@
@@FieldValueStartMarker()@@
@@Field@@
@@FieldValueEndMarker()@@
@@FieldEndMarker()@@
And the following code outputs a single-value, editable empty field:
@@FieldStartMarker(Fields.Address.HouseNumberAddition)@@
@@FieldValueStartMarker()@@
@@FieldValueEndMarker()@@
@@FieldEndMarker()@@
In both examples, the parameter the FieldStartMarker call is a path to the field from the context Component or Page. In these examples, the field (HouseNumber or HouseNumberAddition) is a field of an embedded field called Address.
If FieldValueStartMarker has no parameter, as in these examples (or a parameter set to 0), it refers to a single-value field; if it has one integer parameter, the integer refers to the index of the value in a multivalue field (zero-based). For example, FieldValueStartMarker(3) refers to the fourth value in a multivalue field.
- If you want to retain more control of how a field is rendered, you can mimic the behavior of the
FieldStartMarker() and FieldValueStartMarker() calls by enclosing the template code that renders your field in a <tcdl:Field> and <tcdl:FieldValue> tag. The <tcdl:FieldValue> tag has two attributes:
xPath
-
the XPath to the field in the Component XML
index
-
the (zero-based) index of the field in the list of Component fields.
Adding an image is a typical scenario that would call for this explicit use of <tcdl:Field> and <tcdl:FieldValue>.
- When you have updated your field-rendering code, save your changes and proceed to the next Template Building Block.
- Access Content Manager Explorer and republish all the Component Templates you modified to the staging Web site. This triggers a republish of all Components that were rendered with these Component Templates.
Results
All fields of Components rendered with this Component Template are now editable inline, and the Components can be moved around on the Web page, or removed from the Web page.