Start page
Start page

Start page / Template development / Template syntax / System objects / #this

#thisAvailable from FirstSpirit Version 5.0

The #this system object is available in all FirstSpirit templates.

#this always represents the object currently being evaluated in the template. The object type returned can, therefore, vary. Possible return values are:

All methods of the relevant object type can then be called on the return value. For example, if it is a page (Page object type), all methods which can also be called on a Page type object can be called on #this.

The general syntax of #this is:

$CMS_VALUE(#this.METHOD)$

Example

Example: Output of properties of the current template (last change)

Outputting certain properties of a template (unique reference name or the date of last change) can be problematic because the generation context does not provide any information about the template currently being used.

For some templates, certain properties can be output via the #global system object. This means that for pages (Page object type), the UID (unique identifier) can be output in the presentation channel, e.g., by calling #global.page.template.uid. However, for sections, this is unreliable since #global.section is not always the desired section (e.g., subsections within content sources).

In FirstSpirit 5.0 and later, the #this system object can be used in this use case. For example:

Outputting the reference name and the date of last change for a section template:

The following call is added to the HTML presentation channel of the section template:

last change for $CMS_VALUE(#this.template.uid)$: $CMS_VALUE(#this.template.changeDate.format("dd.MM.yyyy"))$)

The call then writes the unique reference name (UID) and the date of the last change to the template in the HTML presentation channel every time the template is used.

In principle, this query can be used in all templates. Whether the #this.getTemplate() (Bean syntax: #this.template) method can be accessed depends solely on the object type returned by #this.

A Template type object is returned for the following return values of #this:

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