String properties are very flexible and can be used to specify information such as text to display on a page, URLs for banner images, or meta keywords for search engine optimization.
To add a string property to a template:
The following example shows a variety of string properties:
{
"@description": "${template.description}",
"@group": "Navigation",
"ecr:createDate": "2016-09-12T17:33:58.404+05:30",
"@thumbnailUrl": "thumbnail.jpg",
"ecr:type": "template",
"defaultContentItem": {
"lessLinkText": "Show Less Refinements...",
"numRefinements": "10",
"@name": "Dimension Navigation",
"dimensionId": "",
"moreLinkText": "Show More Refinements...",
"maxNumRefinements": "200",
"sort": "default",
"showMoreLink": false,
"dimensionName": ""
},
<!-- additional elements omitted from this example -->
"typeInfo": {
"boostRefinements": {"@propertyType": "List"},
"buryRefinements": {"@propertyType": "List"},
"dimensionId": {"@propertyType": "String"},
"dimensionName": {"@propertyType": "String"},
"lessLinkText": {"@propertyType": "String"},
"maxNumRefinements": {"@propertyType": "String"},
"moreLinkText": {"@propertyType": "String"},
"numRefinements": {"@propertyType": "String"},
"showMoreLink": {"@propertyType": "Boolean"},
"sort": {"@propertyType": "String"}
}
}
You add a string editor to enable configuration of string properties. The string editor displays in the Experience Manager interface as a text field or text area depending on the configuration.
String editors enable content administrators to supply arbitrary values for a string property. If you want to constrain the input to a specific enumeration of values, use a choice editor.
To add a string editor to a template:
Insert an
editors/StringEditor
element withineditors/DefaultEditorPanel
.Specify label attributes and additional attributes for the editor:
Attribute Description propertyName
Required. The name
of the string property that this editor is associated with. This property must be declared in the same template as the string editor.label
The label for the editor. enabled
If set to false
, this attribute makes the property read-only so that the value of the property displays in the Content Details Panel in Experience Manager, but cannot be edited. Set this tofalse
only if you specify a default value in the definition of the string property. Editors are enabled by default.
The following example shows a variety of editing options for string properties:
{ "@description": "${template.description}", "@group": "Navigation", "ecr:createDate": "2016-09-12T17:33:58.404+05:30", "@thumbnailUrl": "thumbnail.jpg", "ecr:type": "template", "defaultContentItem": { "lessLinkText": "Show Less Refinements...", "numRefinements": "10", "@name": "Dimension Navigation", "dimensionId": "", "moreLinkText": "Show More Refinements...", "maxNumRefinements": "200", "sort": "default", "showMoreLink": false, "dimensionName": "" }, "editorPanel": { "editor": "editors/DefaultEditorPanel", "children": [ <!-- additional elements omitted from this example --> { "editor": "editors/StringEditor", "propertyName": "moreLinkText", "label": "${property.moreLinkText.label}", "enabled": true }, { "editor": "editors/StringEditor", "propertyName": "lessLinkText", "label": "${property.lessLinkText.label}", "enabled": true } ] <!-- additional elements omitted from this example --> } "typeInfo": { "boostRefinements": {"@propertyType": "List"}, "buryRefinements": {"@propertyType": "List"}, "dimensionId": {"@propertyType": "String"}, "dimensionName": {"@propertyType": "String"}, "lessLinkText": {"@propertyType": "String"}, "maxNumRefinements": {"@propertyType": "String"}, "moreLinkText": {"@propertyType": "String"}, "numRefinements": {"@propertyType": "String"}, "showMoreLink": {"@propertyType": "Boolean"}, "sort": {"@propertyType": "String"} } }
Note
Neither Experience Manager nor the Assembler applies HTML escaping to strings. This enables content administrators to specify HTML formatted text in Experience Manager and have it rendered appropriately. If you intend to treat a string property as plain text, be sure to add HTML escaping to your application logic in order to avoid invalid characters and non-standards-compliant HTML.
A choice editor enables the user to select from predefined string values for a property that are presented in a drop-down list. Choice editors affect the value of a string property.
To add a choice editor:
Insert an
editors/ChoiceEditor
element withineditors/DefaultEditorPanel
.Specify additional attributes for the editor:
Attribute Description propertyName
Required. The
name
of the string property that this editor is associated with. This property must be declared in the same template as the choice editor.editable
If set to
true
, this attribute allows Experience Manager users to specify custom string values. By default, choice editors are not editable.enabled
If set to
false
, the choice editor displays in Experience Manager but the value cannot be changed by the user. By default, choice editors are enabled.prompt
Specifies a custom prompt. The default prompt is an empty string. It is enabled only when editable is set to
true
.tooltip
If present, specifies optional help text to display in a tool tip window. The default behavior is no tool tip.
width
The width, in pixels, of the choice editor. By default, the width of the editor adjusts to fit the longest choice in the editor. Use this attribute if you want to set a fixed width for the editor.
Insert an
choices
element within theeditors/ChoiceEditor
elementSpecify one or more menu options for the choice editor by adding elements that takes the following attributes:
Attribute Description value
Required. The string value to assign to the associated property if this choice is selected.
label
This attribute allows you to specify a more descriptive label for this option in the drop down list. If no label is specified, the
value
is used by default. You must either specify alabel
for all of the choices or none of them. You cannot have labels for some choices and not others.Note
If you choose to make a choice editor editable (so that users can enter arbitrary strings), you should not use the
label
attribute for choices. Instead, the choice editor should display the raw value of the string so that users entering custom values can see the expected format of the string property.Optionally, set a default value in the corresponding
defaultContentItem
property.For example,:
"defaultContentItem": { "sort": "default",
Note
Ensure that the default value for the property is one of the options defined for the choice editor in a element.
The following example shows a choice editor configured with a default value.
{ "@description": "${template.description}", "@group": "Navigation", "ecr:createDate": "2016-09-12T17:33:58.404+05:30", "@thumbnailUrl": "thumbnail.jpg", "ecr:type": "template", "defaultContentItem": { "lessLinkText": "Show Less Refinements...", "numRefinements": "10", "@name": "Dimension Navigation", "dimensionId": "", "moreLinkText": "Show More Refinements...", "maxNumRefinements": "200", "sort": "default", "showMoreLink": false, "dimensionName": "" }, "editorPanel": { "editor": "editors/DefaultEditorPanel", "children": [ <!-- additional elements omitted from this example --> { "editor": "editors/ChoiceEditor", "propertyName": "sort", "label": "${property.sort.label}", "choices": [ { "label": "${property.sort.default.label}", "value": "default" }, { "label": "${property.sort.static.label}", "value": "static" }, { "label": "${property.sort.dynRank.label}", "value": "dynRank" } ] }, ] <!-- additional elements omitted from this example --> } "typeInfo": { "boostRefinements": {"@propertyType": "List"}, "buryRefinements": {"@propertyType": "List"}, "dimensionId": {"@propertyType": "String"}, "dimensionName": {"@propertyType": "String"}, "lessLinkText": {"@propertyType": "String"}, "maxNumRefinements": {"@propertyType": "String"}, "moreLinkText": {"@propertyType": "String"}, "numRefinements": {"@propertyType": "String"}, "showMoreLink": {"@propertyType": "Boolean"}, "sort": {"@propertyType": "String"} } }