4

A colleague pointed out the XPM documentation suggests outputting an empty TCDL tag allows authors the ability to edit fields which are not rendered.

2011

<!-- TemplateBeginIf cond="CollectionLength('Field.Values') == 0" -->
 <tcdl:ComponentField name="${Field.Name}"></tcdl:ComponentField>
<!-- TemplateEndIf -->

2013

@@FieldStartMarker(Fields.Address.HouseNumberAddition)@@
  @@FieldValueStartMarker()@@
  @@FieldValueEndMarker()@@
@@FieldEndMarker()@@

What's the equivalent XPM inline editing comment syntax for these?

I'm posting an example below for reference. We've seen questions on making empty fields editable (https://stackoverflow.com/q/12050672/395495), but I wasn't sure of the JSON comment syntax.

5

For this source (note summary field is missing):

<Content xmlns="http://Electridion.com/Schema/Article" xmlns:xlink="http://www.w3.org/1999/xlink">
    <title>Electridion Events</title>
    <description>Description</description>
</Content>

In 2013, I used:

@@FieldStartMarker('summary')@@
  @@FieldValueStartMarker()@@
  @@FieldValueEndMarker()@@
@@FieldEndMarker()@@

Source on Staging:

<span>
  <!-- Start Component Field: {"XPath":"tcm:Content/custom:Content/custom:summary[1]"} -->
</span>

TCDL equivalent in Template Builder:

<tcdl:Field xPath="tcm:Content/custom:Content/custom:summary" itemId="tcm:69-6362-v0">
  <span><!-- Start Component Field: {"XPath":"tcm:Content/custom:Content/custom:summary[1]"} --><tcdl:FieldValue index="0">
  </tcdl:FieldValue></span>
</tcdl:Field>

So it seems the XPath is as it would be if there was a value in the field. All this needs is a check to only output the empty markup if the field is actually empty.

| improve this answer | |
  • "All this needs is a check to only output the empty markup if the field is actually empty." When the field is not empty your template would output the same markup I guess. When we have a template that hides a HTML section (i.e. an H1 which takes space even when it is empty), then we want to render that section with the empty markup but only in staging. Or only when the component is in edit mode in XPM. – Jan H Sep 5 '14 at 7:12
  • I wonder is there any clever trick for DD4T (and the likes) that would allow forging SE markup for unassigned (and effectively non-existing) fields? – esteewhy Oct 2 '14 at 11:08
  • When DD4T serializes the Component XML, what happens for empty fields? If it "knows" about them, I think this would be an interesting, useful exercise (worth trying on the Tridion Reference Implementation). :-) – Alvin Reyes Oct 8 '14 at 2:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.