T
- type parameter for the template fragment implementation@Exported public interface EditableTemplateFragment<T extends EditableTemplateFragment<T>> extends TemplateFragment<T>
TemplateFragment
, and has some additional behavior which are necessary for its editable nature.
An editable template fragment instance can be minimally built as:
EditableTemplateFragment<?> fragment = FragmentFactory.newEditableTemplateFragment() .useTemplate("/HomePage") .forAsset("MyAssetType", "1934567890")The editable fragment supports editing an asset which is different from the asset specified using
TemplateFragment.forAsset(String, String)
.
This is possible by using the EditableTemplateFragment.editAsset(String, String, String)
method.
However, if the asset is not specified (when EditableTemplateFragment.editField(String)
is used instead),
then the asset used by the fragment (whether specified using TemplateFragment.forAsset(String, String)
or looked up from the page context)
is the asset to be edited.
The field of an editable asset has to be an asset reference field:
asset
Association-named:nameOfAssociation
Group_nameOfParentDefinition
ManualRecs
, if the edited asset is a static recommendationcontext
,
which is automatically managed by Sites, i.e. every fragment updates the current context by appending:
<c>:<cid>:<tname>
Note: the context variable is initially empty, and must be properly initialized in layout templates. For example:
<ics:setvar name="context" value='<%=ics.GetVar("c") + ":" + ics.GetVar("cid") + ":SectionLayout"%>' />If context is set to a constant:
fragment.forContext("Global")
, the slot shows the same presentation data across all web pages using the fragment.
Fragment.Scope, Fragment.Style
Modifier and Type | Method and Description |
---|---|
T |
addButtons(String button,
String... more)
Sets buttons to show on the insite overlay.
|
T |
addEditorRoles(String role,
String... more)
Sets roles allowed to modify slot presentation.
|
T |
addLegalTypes(String type,
String... more)
Sets asset types which are allowed to be dropped in this slot.
|
T |
editAsset(AssetId assetId,
String field)
Sets the field of the specified asset to edit.
|
T |
editAsset(AssetId assetId,
String field,
int index)
Sets the field of the specified asset to edit.
|
T |
editAsset(String assetType,
Long assetId,
String field)
Sets the field of the specified asset to edit.
|
T |
editAsset(String assetType,
Long assetId,
String field,
int index)
Sets the field of the specified asset to edit.
|
T |
editAsset(String assetType,
String assetId,
String field)
Sets the field of the specified asset to edit.
|
T |
editAsset(String assetType,
String assetId,
String field,
int index)
Sets the field of the specified asset to edit.
|
T |
editField(String field)
Sets the field of the asset specified by
TemplateFragment.forAsset(String, String) to edit. |
T |
editField(String field,
int index)
Sets the index of the specified multi-valued field of the asset specified by
TemplateFragment.forAsset(String, String) to edit. |
T |
forContext(String context)
Sets the context to use for this fragment.
|
T |
setEmptyText(String emptyText)
Sets the text to be rendered inside empty slots.
|
T |
setSlotname(String slotname)
Sets (and hence enables) presentation-editing mode for the specified slot name.
|
T |
setStyles(String styles)
Sets additional CSS classes to add to the slot, whenever CSS rules need to be adjusted
Note: This method does not validate the syntax for the CSS string.
|
T |
setTitle(String title)
Sets the slot title rendered in slot overlays.
|
T |
setVariant(String variant)
Sets the templates which can be selected as an alternative to the template specified using
TemplateFragment.useTemplate(String) . |
addArgument, forAsset, forAsset, forAsset, inSite, invokeFrom, resolveDevice, setArguments, useArguments, useDevice, useStyle, useTemplate
T setEmptyText(String emptyText)
emptyText
- the text to setT setTitle(String title)
title
- the title to setT setStyles(String styles)
styles
- the CSS styles to setT addButtons(String button, String... more)
button
- a button to showmore
- optional more buttons to show.T addEditorRoles(String role, String... more)
role
- a role to allow for modifying slot presentationmore
- optional more roles to allowT addLegalTypes(String type, String... more)
assetType:subtype
, or assetType:*
type
- an asset type to be allowedmore
- optional more asset types to allowT editField(String field)
TemplateFragment.forAsset(String, String)
to edit.
The field has to be an asset reference field.
Use this method for single-valued fields only.
For multi-valued fields, use EditableTemplateFragment.editField(String, int)
field
- the asset reference fieldT editField(String field, int index)
TemplateFragment.forAsset(String, String)
to edit.
The field has to be an asset reference field.
Use this method for multi-valued fields only.
For single-valued fields, use EditableTemplateFragment.editField(String)
field
- the asset reference fieldindex
- the index in ordered sequence of values in the multi-valued fieldT editAsset(String assetType, String assetId, String field)
EditableTemplateFragment.editAsset(String, String, String, int)
assetType
- the type of the asset to editassetId
- the id of the asset to editfield
- the asset reference fieldT editAsset(String assetType, Long assetId, String field)
EditableTemplateFragment.editAsset(String, String, String, int)
assetType
- the type of the asset to editassetId
- the id of the asset to editfield
- the asset reference fieldT editAsset(AssetId assetId, String field)
EditableTemplateFragment.editAsset(String, String, String, int)
assetId
- the id of the asset to editfield
- the asset reference fieldT editAsset(String assetType, String assetId, String field, int index)
EditableTemplateFragment.editField(String)
assetType
- the type of the asset to editassetId
- the id of the asset to editfield
- the asset reference fieldindex
- the index in ordered sequence of values in the multi-valued fieldT editAsset(String assetType, Long assetId, String field, int index)
EditableTemplateFragment.editField(String)
assetType
- the type of the asset to editassetId
- the id of the asset to editfield
- the asset reference fieldindex
- the index in ordered sequence of values in the multi-valued fieldT editAsset(AssetId assetId, String field, int index)
EditableTemplateFragment.editField(String)
assetId
- the id of the asset to editfield
- the asset reference fieldindex
- the index in ordered sequence of values in the multi-valued fieldT setSlotname(String slotname)
TemplateFragment.useTemplate(String)
.
The slot name should be unique across all templates.slotname
- the slot nameT setVariant(String variant)
TemplateFragment.useTemplate(String)
.
This restriction is allowed only when presentation editing mode is enabled (using EditableTemplateFragment.setSlotname(String)
).variant
- the regular expression which specifies which templates can be selected