Information About the Execution Environment
Part of FirstSpirit's product strategy is to provide numerous extensibility opportunities. The easy implementation of project-specific modifications and extensions may be done via scripts, plug-ins and executables.
Depending on the use case, extensions require further information. For example, when calling a script within a workflow, the script must be aware of its execution environment - ContentCreator or SiteArchitect (see Use Case ContentHighlighting).
This information may be polled either directly via a BaseContext object or via the system object #global. This call uses constants of the Enum BaseContext.Env as a parameter.
Currently, the following information about the execution environment may be polled:
- PREVIEW: Execution takes place within the integrated preview
- WEBEDIT: Execution takes place within ContentCreator
- ARCHITECT: Execution takes place within SiteArchitect
- MANAGER: Execution takes place within ServerManager
- FS_BUTTON: Execution takes place associated with an FS_BUTTON
- DROP: Execution takes place due to a drag-and-drop interaction
- GENERATION: Execution takes place during a generation run
- FORM: Execution takes place within an input component
- REPORT: Execution takes place within a report
- HEADLESS: Execution takes place in an environment without GUI (e.g. server-side scripts)
- WEB: Execution takes place in a web application
Depending on the execution environment, several polls with different Enum constants may return true at the same time, e.g.:
- PREVIEW, WEBEDIT for a rendering script (generation context) in ContentCreator
- FS_BUTTON for an FS_BUTTON, which was clicked in a SiteArchitect form
- FS_BUTTON, PREVIEW, WEBEDIT, DROP for an FS_BUTTON in ContentCreator on which an image was dropped
Syntax
Request via a BaseContext object and a constant of Enum BaseContext.Env:
import de.espirit.firstspirit.access.BaseContext;
// The variable "context" is of type BaseContext.
if (context.is(BaseContext.Env.WEBEDIT)) ...
or when accessing the BaseContext instance:
if (context.is(context.Env.WEBEDIT)) ...
In output channel definitions with Enum conversion, the following, short syntax using a String object is also possible:
$CMS_IF( #global.is("WEBEDIT") )$ ...
Not all keywords can be used with the template syntax. |