Start page
Start page

Start page / Template development / Scripting / Making scripts

Making scripts

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 scope can be selected.

General

Reference name: Script reference name.

Comment: An optional comment that describes the script in more detail can be entered here.

Keyboard shortcut: A unique keyboard shortcut can be defined for a script in this field. In this case, the script does not have to be run using the context menu or the “Extras” menu, instead it can be called directly using the defined keyboard shortcut. The cursor has to be inside this field to define a new keyboard shortcut. Then entering the desired key combination using the keyboard is all that is needed. The input is then applied in the input field. Text input is not possible. To change the keyboard shortcut, reposition the cursor in the field and then select the new key combination. Press the icon to delete the defined keyboard shortcut for the script.
Keyboard shortcuts can only be used for scripts of "Context menu" or "Menu" “Menu”, “Menu and Homepage” and “Context menu” type.

Display

Scripts can be configured for individual scopes:

  • Template: The script can be called and run in a template using $CMS_RENDER(script:..)$, e.g. for rendering specific content for the PDF presentation channel:

<fo:table table-layout="fixed" width="170mm">
$CMS_RENDER(script:"fotablecolumns",colWidth:set_cw,colNumbers:set_cn)$
<fo:table-body>
$CMS_VALUE(#content)$
</fo:table-body>
</fo:table>

  • Menu: The script can be run in SiteArchitect using the Extras > Execute Script menu.
  • Menu and Homepage: The script can be run in SiteArchitect using the Extras > Execute Script menu or the homepage (Icon project home icon, area “My actions”).
  • Context menu: The script can be called and run on a specific element in FirstSpirit SiteArchitect's tree view or on a path in the editing area using the context menu.
  • Uninterpreted: The content of the script can be called in the header of a template. The script is not checked against BeanShell syntax when saved. This allows HTML syntax to be saved (such as for displaying list elements). These scripts should no longer be used.

For further information about contexts see this page.

Important The corresponding templates are to be converted to format templates in projects that use uninterpreted scripts. For this reason, it will no longer be possible to save scripts of this type until the scripts have been converted to another script type. This type is no longer available for newly created scripts.
Important Scripts of the types “Menu” and “Menu and Homepage” are displayed in the “Actions” menu in ContentCreator.

Display: The display logic can be used to show or hide scripts of the type “Menu”, “Menu and Homepage” or “Context menu” depending on specific properties (analogous to the display logic of workflows). 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.getElement();
return (storeElement instanceof PageRef);

The stored display logic will be taken into account if the option “Use display logic” is active.

Display always: The “Display always” checkbox can be unchecked if the display logic is to be disabled. In this case, the script is always displayed, regardless of the display logic. The stored display logic is no longer evaluated, but it remains stored and can be reenabled by unchecking 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. Specifying the character string //! Beanshell in the first line of a script causes the system to interpret the following source text as BeanShell script.

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.

© 2005 - 2015 e-Spirit AG | All rights reserved. | Last change: 2014-03-24