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

Project-related #global invocations

The requirements of a website can make it necessary to access the settings or other project information. For example, if a language change is to be enabled within the website it is useful to determine the defined project languages beforehand.

For such purposes, the system object #global enables the project's properties to be accessed. This is done using the expression #global.project, which returns an object of data type Project.

The most important invocations are listed in the following table:

Invocation

Meaning

Return data type

#global.project.brtemplate setokenLinkMedia

Returns the name of the set replacement medium

String
(character string)

#global.project.brokenLinkPage

Returns the name of the set replacement page

String
(character string)

#global.project.description

Returns the description of the project
(see page Adding a new project in the "Tutorials" area).

String
(character string)

#global.project.id

Returns the project's ID.

Long

#global.project.groups

Returns all groups of a project
(see also page about the Project properties in the "Tutorials" area).

List<Group>

#global.project.languages

Returns all languages of a project
(see page about the Server and Project properties in the "Tutorials" area). The method .shouldGenerate() of the data type Language can be used to check whether a language is generated or not.

List<Language>

#global.project.masterLanguage

Returns the master language of a project
(see also page about the Project properties in the "Tutorials" area).

Language

#global.project.masterLanguage.abbreviation

Returns the abbreviation of the master language of a project.

String
(character string)

#global.project.masterLanguage.name

Returns the name of the master language, e.g. German, English etc.

String
(character string)

#global.project.name

Returns the name of the project
(see page Adding a new project in the "Tutorials" area).

String
(character string)

#global.project.originalResolution

Returns the original resolution
(see also page about the Project properties in the "Tutorials" area).

Resolution

#global.project.resolutions

Returns all resolutions of a project. The method .isOriginal() of the data type Resolution can be used to check whether the resolution is the original resolution or not.

List<Resolution>

#global.project.templateSets

Returns all template sets of a project.

List<TemplateSet>

#global.project.users

Returns all users of a project
(see page about Creating and Adding users to a project).

List<User>

#global.project.remoteProjectConfigurations

Returns all remote project configurations
(see also relevant page in the "Advanced topics" area).

List <RemoteProjectConfiguration>

   

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: Drop-down box with all generated project languages

<select size="1" name="language" onchange="window.location.href=this.options[this.selectedIndex].value">
$CMS_FOR(l, #global.project.languages)$
$CMS_IF(l.shouldGenerate)$
<option value="$CMS_REF(#global.node, lang:l.abbreviation)$">$CMS_VALUE(l.name + " (" + l.abbreviation + ")")$</option>
$CMS_END_IF$
$CMS_END_FOR$
</select>

In the example, all project languages are determined with #global.project.languages . The $CMS_FOR(...)$ instruction is now used to treat each individual project language. If the Generate Language option is activated for the language (project settings: Lanugages; Check with .shouldGenerate()), a drop-down box entry is output. The name of language and in addition (enclosed in brackets) the abbreviation are displayed in the drop-down box. The aim of the entry is the current page in the relevant language.

Exemplary output:

<select size="1" name="language" onchange="window.location.href=this.options[this.selectedIndex].value">
<option value="/preview/671041/show/site/DE/current/671044/681046">Deutsch (DE)</option>
<option value="/preview/671041/show/site/EN/current/671044/681046">English (EN)</option>
<option value="/preview/671041/show/site/ES/current/671044/681046">Español (ES)</option>
</select>

2nd Example: Output of a picture in all project resolutions

$CMS_FOR(r, #global.project.resolutions)$
<p>
$CMS_IF(r.isOriginal)$
<img src="$CMS_REF(media:"florida")$"/>
<p>Picture -
unscaled
- ($CMS_VALUE(ref(media:"florida").width)$x$CMS_VALUE(ref(media:"florida").height)$)</p>
$CMS_ELSE$
<img src="$CMS_REF(media:"florida", res:r)$" />
<p>Picture -
$CMS_IF(r.width > 0)$
width-scaled
$CMS_IF(r.height > 0)$
and height-scaled
$CMS_END_IF$
$CMS_ELSIF(r.height > 0)$
height-scaled
$CMS_END_IF$
- ($CMS_VALUE(ref(media:"florida", res:r).width)$x$CMS_VALUE(ref(media:"florida", res:r).height)$)</p>
$CMS_END_IF$
</p>
$CMS_END_FOR$

In the example, all resolutions are determined with #global.project.resolutions . The $CMS_FOR(...)$ instruction is now used to treat each resolution individually:

  • If it is the original resolution (.isOriginal), the picture is output unscaled with the text "Picture - unscaled - " and the width and height in pixels.
  • For other resolutions the picture is output with the corresponding resolution. At the same time it is determined whether the width and/or height of the picture is scaled and then the corresponding width and height is output in pixels. A picture is always scaled if either the width or the height specification in the resolution has a value greater than 0.

Exemplary output:

<p>
<img src="/preview/671041/show/media/DE/current/773042/ORIGINAL"/>
<p>Picture - unscaled - (4134x2766)</p>
</p>
<p>
<img src="/preview/671041/show/media/DE/current/773042/W100" />
<p>Picture - width-scaled -(100x67)</p>
</p>
<p>
<img src="/preview/671041/show/media/DE/current/773042/H100" />
<p>Picture - height-scaled -(149x100)</p>
</p>

3rd example: Filtering project properties

In some cases it can be of benefit to filter some of the amount of project properties (as for example languages, resolutions, template sets, users) by specific criteria for becoming able to apply specific methods in them.

For this purpose the method .filter can be used. (See also page Mapping expressions (lambda).)

Subset

Syntax

all languages of a project

$CMS_VALUE(#global.project.languages)$

all languages of a project except for the master language

$CMS_VALUE(#global.project.languages.filter(x -> !x.masterLanguage))$

all languages of a project which are generated

$CMS_VALUE(#global.project.languages.filter(x -> x.shouldGenerate))$

all languages which are generated except for the master language

$CMS_VALUE(#global.project.languages.filter(x -> !x.masterLanguage && x.shouldGenerate))$

all resolutions of a project

$CMS_VALUE(#global.project.resolutions)$

all resolutions of a project except for the resolution ORIGINAL

$CMS_VALUE(#global.project.resolutions.filter(x -> !x.original))$

all users of a project

$CMS_VALUE(#global.project.users)$

all users of the project which are project administrator

$CMS_VALUE(#global.project.users.filter(x -> x.isProjectAdmin(#global.project)))$

all remote project configurations of a project

$CMS_VALUE(#global.project.remoteProjectConfigurations)$

all remote project configurations except for the locale project

$CMS_VALUE(#global.project.remoteProjectConfigurations.filter(x -> x.projectName != #global.project.name))$

  

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