Making scripts
Create client script
New scripts can be created in the Scripts folder in the Template Store, by using the context menu, item "New" / "Create new script".
Properties
A description and comment can be set in the Properties tab of a Script and the template type can be selected.
The Script type offers the possibility of using the script with 4 different options:
- Template: Script can be invoked in a template and executed in the generation context
- Menu: Invoke via the main menu in the JavaClient under the item: Extras > Execute Script
- Context menu: Invoke via the context menu on each Store node in the project
- Uninterpreted: In this way the content of the script can be opened in the header of a template
Furthermore, a unique keyboard shortcut can be defined using the field Keyboard shortcut. In this case the script no longer has to be executed via the context menu or the "Extras" menu but instead can be opened directly via the defined keyboard shortcut.
For scripts of the type Menu the option Use on homepage can be activated. The respective script will then be displayed on the project homepage in the "My actions" area and can be executed by clicking on the link.
View Logic (only for menu/context menu): The view logic can be used to show or hide scripts depending on specific properties (analogous to the view logic of workflows, cf. FirstSpirit Documentation for Developers). For example, a script of the type "Context menu" can only be displayed if the context menu is opened on a page reference in the Site Store:
//!Beanshell
import de.espirit.firstspirit.access.store.sitestore.PageRef;
storeElement = context.getStoreElement();
return (storeElement instanceof PageRef);
Always active: The "Always active" checkbox can be selected if the view logic is to be disabled. In this case the script is always shown, regardless of the view logic. The deposited view logic is no longer evaluated, but is retained and can be reactivated by deselecting the checkbox.
Form
Analogous to page and section templates, individual input components can be defined in the form which can be invoked for the runtime of the script. The values of the input components can be returned to the script for processing.
Output channels
The output channels (e.g.: HTML, JSP, print, etc.) contain the actual BeanShell source code. FIRSTspirit recognises that this script is BeanShell from the first row of the example.
//!Beanshell
print("My First Script!");
If the script is to be executable in each output channel, each channel must be filled with the script code.