Scripts pane
The Scripts pane contains all of the scripts that are used to replace data in a template, or to modify its look; see Personalizing content.
The scripts are stored in three groups: Control, Standard and Post Pagination, depending on when they run (see The script flow: when scripts run).
Note: The scripts in each of the main folders - Control, Standard and Post Pagination - are executed top-to-bottom. They can be dragged up or down in the pane to change their order of execution. For example, content-loading scripts (snippets with variable data, for instance) must come before scripts that replace data within loaded contents.
The Script pane allows to add and edit scripts and to manage scripts, or instance by organizing them in subfolders and enabling/disabling them (see Managing scripts).
Scripts can be exported and imported via the buttons or through drag & drop between the Scripts pane and any location on the computer.
Scripts have access to the whole OL Connect JavaScript API (see Standard Script API), such as the record
object.
Note: Scripts included on the Scripts pane are completely distinct from the JavaScript resources found in the Resources pane (see Using JavaScript).
Think of scripts as server-side in the sense that they are executed through the Connect modules (Server and Content Creation especially). JavaScript resources don't have access to the OL Connect JavaScript API. They are only executed after the content creation is done, generally in a browser.
Buttons
-
Debug Scripts... : Opens the Script Debugger.
-
View Menu : Displays a drop-down that shows the following options:
Import...: Click to open a standard Open dialog to import a script. The script must have the .OL-script extension.
Export...: Click to open a standard Save As dialog to save the currently selected scripts to disk. These scripts can be re-used in other templates. If more than one script is selected, they are all saved to a single file. If some scripts are inside folders, this folder structure is kept and will be restored when the scripts are imported.
-
New: Displays a drop-down that shows the following options:
-
Control Script: A Control Script affects the output of a template per record as a whole, instead of parts of the content. See Control Scripts and Control Script API.
-
Remote Control Script: Opens a dialog to add a remote Control Script. See Control Scripts and Control Script API.
-
Standard Script: Adds a new empty standard script. Double-clicking the new script opens the script editor, where you can write code (see Writing your own scripts).
Tip: Select Text Script instead of Standard Script to create a Standard script that is opened with the Text Script Wizard.
-
Post Pagination Script (Print context only): Adds a Post Pagination script, which runs on the Print context after the output has been paginated (see Post Pagination Scripts).
-
Folder: Adds a folder in which scripts can be placed for easier management. See Script folders.
-
Text Script: This type of script inserts variable data in the text. See Variable data in text: scripts and placeholders.
-
Dynamic Image script: Provided that its selector refers to an image, this script dynamically changes the image for each record. See Dynamic images.
-
Dynamic Background Script: This type of script dynamically changes the background of a Print section. See Dynamic Print section backgrounds.
-
Email scripts (Email sections only): Email scripts define the sender, recipients, subject, dynamic attachments etc. of the email that is sent, and the PDF password. See Email header settings.
-
Conditional Content Script: This script can conditionally show or hide any element in the template. See Showing content conditionally and Conditional Content script dialog.
-
Conditional Print Section Script: This script conditionally shows or hides any Print section in a template. See Conditional Print sections.
-
-
Collapse All: Collapses all the folders, hiding the scripts inside of them.
Scripts Pane filter
To quickly find a certain script or piece of code, type a search text in the filter field located below the buttons in the Scripts pane.
The Scripts Pane will then only display scripts of which the name, selector or content matches the search text. This is case insensitive.
Scripts Pane column
-
Name: The name added to better identify the script.
-
Selector: Displays the initial text or selector that the script applies to. See Selectors in OL Connect. Control Scripts and Post Pagination Scripts do not have a selector (see Control Scripts and Post Pagination Scripts).
Tip: Fields from the Data Model pane can be dragged directly into the Scripts pane to create a Text Script. Additionally, Text scripts can be dragged into any section to add the script's placeholder at the insert location. See Variable data in text: scripts and placeholders.
Contextual menu options
-
New: Click to create a new script or folder. See Buttons for a description of all options. Which script types are available depends on the current section and script folder.
-
Duplicate: Click to create an exact copy of the script.
-
Delete: Click to delete the selected script. This does not delete any element or text in the template itself.
-
Rename: Click to open a dialog to rename the script. This is the same as changing the Name field in the Edit Script window, which can be opened by double-clicking the script.
-
Enable/Disable: Click to trigger the script to be enabled or disabled. Disabled scripts are greyed out and italic and will not be executed. See Enable/disable scripts
-
Import: load a script from a Scripts file (*.OL-script).
-
Export: save the script to a Scripts file (*.OL-script).
-
Properties (Script folders only): edit the name and execution scope of the folder. See Execution scope.