Start page / Template development / Template syntax / System objects / #global / Preview-specific

Preview-related #global invocations

Contents

The preview of a page should frequently have other functions than the published (deployed) or generated status of this page. For example, status information or an editing function for the editor may be required within a preview.

A further requirement is language-dependent preview generation. For example, it is possible that the layout of a page differs depending on the language or that the language affects the output formatting. In addition, it is possible to prevent a special page from being generated in a specific template set.

To fulfil these and other requirements the #global system object provides the option to access information in the preview, deployment and generation and to influence them.

The following table shows the preview-related operations:

Parameters

Invocation

Meaning

Return data type

#global.context

Returns the current context.

Context

#global.context("IDENTIFIER")

Returns a special context.
For IDENTIFIER the technical name of the desired context must be given. This can be retrieved using #global.dumpcontext. For further information about contexts see Chapter Contexts.

Context

#global.dumpcontext

Output of all context information for easier troubleshooting/debugging

String
(character string)

#global.dumpcontext("SEPARATOR")

Output of all context information for easier troubleshooting/debugging, however with specification of separators for the output of the individual rows, e.g. <br>.

String
(character string)

#global.encoding

Returns the given HTML encoding for the language, which is currently being generated, e.g. ISO-8859-1, UTF-8.
If HTML encoding was not specified in the project settings for a language the system encoding is returned

String
(character string)

#global.is("...")

Determines the execution environment based on a keyword.
Possible keywords:

  • WEBEDIT
  • PREVIEW
  • FS_BUTTON
  • DROP
  • HEADLESS

Example: Using the keyword WEBEDIT determines whether an HTML page was opened in SiteArchitect or ContentCreator. If the page was opened in ContentCreator, the expression
#global.is("WEBEDIT")
returns TRUE within the HTML template. Further information on the key terms can be found on the Information About the Execution Environment page.

Boolean
(Boolean value)

#global.isRelease

Determines whether the display of the object (e.g. page or page reference) is the release status or not.
true = release status
false = current status

Boolean
(Boolean value)

#global.language

Returns the language currently being generated.

Language

#global.language.abbreviation

Returns the abbreviation of the language currently being generated, e.g. DE, EN etc.

String
(character string)

#global.language.name

Returns the name of the language currently being generated, e.g. German, English etc.

String
(character string)

#global.now

Returns the current (today's) date.

Date

#global.preview

Determines whether the display of the object (e.g. page or page reference) is a preview or not.
true = preview
false = not a preview (e.g. deployment, generation, etc.)

Boolean
(Boolean value)

#global.previewRulesEvaluation

De-/activates rule evaluation during generation of the ContentCreator preview.
true = rules will be evaluated and visualized without limitation
false = rule evaluation during preview generation in ContentCreator will be deactivated (see also editorId function).
Example: $CMS_SET(#global.previewRulesEvaluation, true)$
See also paragraph “Deactivating rule evaluation during generation of the ContentCreator preview” below.

Boolean
(Boolean value)

#global.project

Returns the project.

Project

#global.project.id

Returns the project's ID.

Long

#global.scheduleContext

Access to information of generation schedules: This call can be used to access the execution context of a generation schedule and therefore to access information such as the name of the project, the starting time of the schedule, the path to the generation directory, the number of errors during generation, etc.
For further information about contexts see Chapter Contexts.

ScheduleContext

#global.startDate

Synonym for #startdate

Date

#global.version

Returns the FirstSpirit version number, e.g. 5.0.14

String
(character string)

   

Enhanced error logging mode

The enhanced error logging mode (see also Chapter Scripting) is activated with the following expression:

$CMS_SET(#global.debugMode, true)$

Cancel a generation

It is possible to prevent the generation in a template. This is useful if generation is not wanted in the template set of a page template (e.g. no PDF version of a document, etc.)

The expression to prevent generation is:

$CMS_SET(#global.stopGenerate, true)$

Deactivating rule evaluation during generation of the ContentCreator preview

Using the previewRulesEvaluation parameter rule evaluation (see also Chapter Rules) during preview generation in ContentCreator can be deactivated. This can be useful if rule evaluation causes long computation times during preview generation and thus impacts ContentCreator's performance.

Important This functionality only affects the preview in ContentCreator; in forms in ContentCreator and in SiteArchitect, rule evaluation will continue to be carried out, and rule infractions will continue to be visualized if they are detected.

Note: For content based on table templates (datasets), rule infractions are never visualized in the preview

Possible values of this parameter are:

  • true: default value if #global.previewRulesEvaluation is not set; the rules defined for this template (tab “Rules”) will be evaluated and visualized without limitation.
  • false: rule evaluation during preview generation in ContentCreator will be deactivated. In forms in ContentCreator and in SiteArchitect, rule evaluation and visualization of validation problems will be carried out as usual.

Example:

$CMS_SET(#global.previewRulesEvaluation, false)$

Explanation: Following the call $CMS_SET(#global.previewRulesEvaluation, false)$, rule evaluation during preview generation in ContentCreator will be disabled for all subsequent calls to editorId(), for example:

$CMS_SET(#global.previewRulesEvaluation, false)$ 
<div$CMS_VALUE(editorId())$>
NO VALIDATION
</div>

For a differentiating configuration within a template, #global.previewRulesEvaluation can be combined with the previewRulesEvaluation parameter of the editorId() function, for example:

$CMS_SET(#global.previewRulesEvaluation, true)$ 
<div$CMS_VALUE(editorId())$>
WITH VALIDATION
</div>
<div$CMS_VALUE(editorId(previewRulesEvaluation:false))$>
NO VALIDATION
</div>

or

$CMS_SET(#global.previewRulesEvaluation, false)$ 
<div$CMS_VALUE(editorId())$>
NO VALIDATION
</div>
<div$CMS_VALUE(editorId(previewRulesEvaluation:true))$>
WITH VALIDATION
</div>

The evaluation of rules is tied to a visualization: in ContentCreator, rule infractions on the page that is currently displayed in the preview are shown in the page status and are indicated by a specific icon and highlighting (see also page Display in ContentCreator).
If rule evaluation during preview generation is deactivated by the options described above, any validation problems that would have been detected by these rules will not be displayed in ContentCreator.

Activating LiveEdit

LiveEdit bases upon the same “editorIds” as Content Highlighting and EasyEdit.

Add the following expression in the desired page templates and these “editorIds” will be created also outside the preview:

$CMS_SET(#global.forceEditorIds, true)$

Adjusting stack size

For security reasons, stack size is limited in FirstSpirit. Occasionally, this may lead to an “Endless loop” exception when nesting of templates would cause the stack to overflow. For example, input components of types CMS_INPUT_DOM and CMS_INPUT_DOMTABLE which use nested lists may lead to this exception. In such a case, content may be output incompletely, and the following message will be logged:

19.11.2015 16:07:07.808 ERROR ($CMS_VALUE(#content)$ at 5, 5): Endless loop in template?

In order to increase stack size, the variable #global.maxStackSize may be adjusted in a template, e.g.

$CMS_SET(#global.maxStackSize, 200)$

The default value for stack size in templates is 75.
This default value for stack size can be customized server-wide using the parameter

generate.defaultMaxStackSize

in the fs-server.conf file (Server (→Documentation for Administrators)).

For further reference, see the method setMaxStackSize in the interface de.espirit.firstspirit.access.template.Evaluator in the FirstSpirit Access API.

Examples

Several examples of use of the instruction within templates are shown in the following. The examples are intended to clearly show the specific effect of the instruction and provide help for the template developer when creating their own templates.

Important The examples displayed here must be adjusted for use within a project! For example, variable names must be changed to the specific variable names of the project in which the instruction is to be used.

1st Example: Language-specific output of the date

$CMS_IF(#global.language.abbreviation == "DE")$
$CMS_VALUE(#global.now.format("dd.MM.yyyy"))$
$CMS_ELSE$
$CMS_VALUE(#global.now.format("MM/dd/yyyy"))$
$CMS_END_IF$

In the example, in the language with the abbreviation DE the current date is displayed in the notation Day, Month and Year - separated by a dot. For all other languages the current date is output in the notation Month, Day and Year.

Output for language with the abbreviation DE:

22.05.2007

Output for all other languages

05/22/2007

2nd Example: Greeting in the preview

$CMS_IF(#global.preview)$
Welcome to our Intranet site
$CMS_END_IF$

The sentence Welcome to our Intranet site is output in the preview.

3rd Example: Dynamic HTML framework

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="$CMS_VALUE(#global.language.abbreviation.toLowerCase)$" lang="$CMS_VALUE(#global.language.abbreviation.toLowerCase)$">
<head>
...
<meta http-equiv="content-type" content="text/html; charset=$CMS_VALUE(#global.encoding)$" />
...

Depending on the generated language, the language abbreviation is used in lower case letters for XML language information.

Further, the given language encoding is used.

Output:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
<head>
...
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
...

© 2005 - 2024 Crownpeak Technology GmbH | All rights reserved. | FirstSpirit 2024.12 | Data privacy