Accessing Field Editors
The EditorControl
object passed into an event
listener by the editor-active
event (see
Handling Events) allows you to access any
content item field editor it contains. You can retrieve the value of any
field displayed in the editor, and you can also set the value of any
field (unless it has been defined as read-only). You can do this both
for content item editors and section page editors.
The EditorControl
object provides both
getValue()
and setValue()
methods
for accessing fields and an isReadOnly()
method for
checking the read-only status of fields. All of them have a
path parameter used to identify the required
field. To access a field in a content item editor
path is simply the name of the field. For
example:
title = editorcontrol.getValue('title');
To access the same field belonging to a content item teaser on a section page, however, requires a more complex path. If the content item is in a top-level area belonging to the root group, then the path has the following form:
com.escenic.indexPage/
area/
index/
field
where:
-
area is the name of the top level area containing the content item
-
index is the position of the content item in the area (starting from 0)
-
field is the name of the content item field
For example:
title = editorcontrol.getValue('com.escenic.indexPage/contentArea/3/title');
If the content item is in a subarea, then you drill down to it by repeating area and index (group names are not used). For example:
title = editorcontrol.getValue('com.escenic.indexPage/contentArea/0/main-area/3/title');
For more information, see EditorControl.