Functions in the preview
Contents |
To help project developers implement complex applications in the preview area, ContentCreator offers several internal Java classes that use specific, content-related functions in conjunction with the FS_BUTTON input component (via so-called FS_BUTTON handler classes).
The classes listed below support use both in onClick and in onDrop attributes of FS_BUTTON components. For drag-and-drop to function, in the section or table templates which are to be used to create new content with drag-and drop, the Drop Editor combo box on the “Properties” tab of the corresponding template must be configured accordingly.
Note: Within the form template, the FS_BUTTON handler classes can be added via the abbreviated form “class:ABBREVIATION” (e.g., onClick="class:NewSection" instead of onClick="class:de.espirit.firstspirit.webedit.server.executables.NewSectionExecutable"). |
Creating a section ("NewSection")
de.espirit.firstspirit.webedit.server.executables.NewSectionExecutable
A click action on the FS_BUTTON triggers the display of a list of section templates that are available in the defined context (by parameters, page and content area). After the user selects one of these templates, an Edit dialog appears which the user can use to modify and save the content of the new section. If only one section template is available in the context, the Edit dialog will appear right away.
A drop action on the FS_BUTTON creates a new section if:
- There is only one matching section template (must be approved for the corresponding content area and the drop object must be compatible with the Drop Editor) and
- The new section to be created is not violating any rules that would prevent saving (scope="SAVE") and
- There are no mandatory fields that have not been completed (e.g., parameter allowEmpty="no")
Otherwise, the list of available section templates or the edit dialog for the section is displayed.
Note: A new section can also be created through programming via the NewSectionOperation interface (de.espirit.firstspirit.webedit.server package, FirstSpirit Access API). Using the method preselectedLanguage a language can be selected, which is displayed to the editor as preconfigured language for editing when the form is opened. If no preselection is made, the language of the preview is displayed when editing. If a language is selected which is not configured in the project, an error message is given out.
Parameter | Description |
---|---|
page | ID or UID of the page
|
body | Content area display name |
store | Page Content store or Global Content |
reload | Partial reload |
Example: Adding a new section (Page store)
The desired FS_BUTTON handler class (in this case: onClick="class:NewSection") is simply specified in the form template. The form template defines how the button is displayed (label, style, icon) and the action associated with the button (in this case: add section):
<FS_BUTTON
name="pt_createSection"
hidden="yes"
icon="fs:new"
onClick="class:NewSection"
onDrop="class:NewSection"
style="firstspirit"
useLanguages="no">
<LANGINFOS>
<LANGINFO lang="*" label="Create section"/>
<LANGINFO lang="DE" label="Absatz anlegen"/>
</LANGINFOS>
</FS_BUTTON>
The relevant HTML code is rendered in the HTML template set inside a $CMS_VALUE(...)$ instruction via the fsbutton(...) function. To do this, the input component (in this case: “pt_createSection”) must be specified via the mandatory parameter editorName. Additional parameters specified are the page ID (#global.page.id) and the content area (in this case: “Content center”) (see the fsbutton(...) function for more examples).
<span$CMS_VALUE(
fsbutton(
editorName:"pt_createSection",
parameter:{
"page":#global.page.id,
"body":"Content center"
}
)
)$></span>
Creating a page ("NewPage")
de.espirit.firstspirit.webedit.server.executables.NewPageExecutable
A click action triggers the display of the “Create new page” dialog. All configurable settings for naming a page, defining where the page will be saved, selecting the appropriate template for the layout, and possible content are available to the user.
A drop action on the FS_BUTTON also opens the “Create new page” dialog, if the dropped object is a FirstSpirit page or page reference. The following settings are made by default in the dialog:
- Names: Language-dependent display names of the dropped page/page reference
- Navigation: Create menu item under current page
- Layout: Take layout and content from dropped page/page reference
These settings thus create a copy of the dropped page/page reference underneath the current page. However, they can be modified by the editor as necessary in this dialog.
Parameter | Description |
---|---|
none | |
Example:
<span$CMS_VALUE(
fsbutton(
editorName:"pt_createPage"
)
)$></span>
Creating a dataset ("NewContent")
de.espirit.firstspirit.webedit.server.executables.NewContentExecutable
A click action triggers the display of the “New dataset” dialog, which is used for editing the content and then saving the new dataset. The dataset created in this action is based on the table template of the data source specified via the content2 parameter.
A drop action on the FS_BUTTON creates a new dataset in the data source specified with the content2 parameter if:
- a Drop Editor that is compatible with the drop object is configured in the underlying table template
- the new dataset to be created is not violating any rules that would prevent saving (scope="SAVE") and
- there are no mandatory fields that have not been completed (e.g., parameter allowEmpty="no")
Otherwise, the edit dialog for the new dataset to be created is displayed.
Parameter | Description |
---|---|
content2 | ID or UID of a data source |
Example:
<span$CMS_VALUE(
fsbutton(
editorName:"pt_createDataset",
parameter:{
"content2":"products"
}
)
)$></span>
As an alternative, new datasets can be created in the Data sources view.
Create list entry ("NewListEntry")
de.espirit.firstspirit.webedit.server.executables.NewListEntryExecutable
This class is available for the following list input component types:
It is used to create a new entry in these input components.
A click action on the FS_BUTTON triggers the display of a list of templates that are available in the list input component defined by the editorId parameter. After the user selects one of these templates, an Edit dialog appears which the user can use to modify and save the content of the new section. If only one template is available in the context, the Edit dialog will appear right away.
A drop action on the FS_BUTTON creates a new list entry if:
- there is only one matching template (must be approved for the corresponding content area and the drop object must be compatible with the Drop Editor) and
- the new list entry to be created is not violating any rules that would prevent saving (scope="SAVE") and
- there are no mandatory fields that have not been completed (e.g., parameter allowEmpty="no")
Otherwise, the list of available templates or the edit dialog for the input component is displayed.
Restrictions defined by rules (for example NEW property for FS_CATALOG) can be overridden by using this handler class. |
This class is intended to be used within the preview, not in forms. The FS_BUTTON can be hidden in forms by using hidden="yes". |
Parameter | Description |
---|---|
editorId | Identifier of a list input component |
json | Compatibility ContentCreator |
reload | Partial reload |
Example:
<span$CMS_VALUE(fsbutton(
editorName: "button",
parameter: {
"editorId": editorId(editorName:"catalog_links", json: true)
}
))$></span>
Editing menu navigation ("EditMenu")
de.espirit.firstspirit.webedit.server.executables.EditMenuExecutable
This class opens the dialog “Edit Navigation” which is used to adapt the structure of the project (i.e., Site Store folders can be moved and their menu order can be adjusted). In addition, the dialog can be used to edit the menu names of the structure folders.
Alternatively, the navigation can also be conveniently edited using the navigation bar on the left edge of the screen.
Parameter | Description |
---|---|
node | ID or UID of a Site Store element |