Start page / Template development / Snippets / Label / Extract

"Label" and "Extract" fields

Contents

The Label field is used to specify the input component that is to be used for the title of the teaser.

The Extract field is used to specify the input component that is to be used for the text extract of the teaser.

If these fields are left empty, the name of the object and the path are displayed as standard; for datasets, the name of the data source and ID of the dataset are displayed, separated by a # symbol, e.g.,“Press releases: #128”

Snippet definition

The snippet definition is generally created via the entry of a variable name for an input component defined in the template.

In order to be able to handle the returned object, methods that can be used with $CMS_VALUE(...)$ can be implemented. The usable methods are dependent on the returned object type. This means that the individual list entries are usually output using the map(String) method (for more information, see the List data type, for example).

Example
of the output of content from an input component of type CMS_INPUT_DOM:

IDENTIFIER.toText(false)

There, IDENTIFIER is the variable name for an input component of CMS_INPUT_DOM type.

Combination

The content of multiple input components can be linked using a plus sign (+).

Static text

Furthermore, static text can be specified between quotation marks (" "). When combining multiple outputs using a plus sign, a separator should be provided (e.g., a blank space: " "). See below for examples.

Examples by component

The following table lists examples of output options for some input components:

Input component

Output via

Note

FS_CATALOG

IDENTIFIER.map(x
->x.getItem().IDENTIFIER2)

IDENTIFIER2 is a variable name for a template used in the FS_CATALOG input component

FS_CATALOG
(access via snippet)

IDENTIFIER.snippets.map(x
->x.header).toString(" / ")

Output of a snippet field by entering
thumbnail (value of the "Thumbnail" field)
header (value of the "Label" field)
extract (value of the "Extract" field)

CMS_INPUT_CHECKBOX /
CMS_INPUT_LIST
(multiple selection)

IDENTIFIER

Outputs a list of the values selected via the input component (value parameter)

IDENTIFIER.map(x->x.label(#language)).toString(", ")

Outputs the labels (user interface label) of the values selected via the input component, separated by commas (label parameter)

CMS_INPUT_COMBOBOX / CMS_INPUT_RADIOBUTTON
(single selection)

IDENTIFIER

Outputs the value selected via the input component (value parameter)

IDENTIFIER.label(#language)

Outputs the label (user interface label) of the value selected via the input component (label parameter)

FS_DATASET

IDENTIFIER.dataset.formData.IDENTIFIER2

IDENTIFIER2 is a variable name for a dataset selected using FS_DATASET

CMS_INPUT_DOM

IDENTIFIER.toText(false)

Outputs the text saved in the DOM editor

FS_INDEX

IDENTIFIER.values.map(x
->x.formData.IDENTIFIER2).toString(",")

IDENTIFIER2 is a variable name for a table template linked via the DatasetDataAccessPlugin

FS_INDEX in FS_CATALOG

IDENTIFIER.map(x.getItem().IDENTIFIER2.values.map(y
->y.formData.IDENTIFIER3).toString(",")


IDENTIFIER2 is the name of the FS_INDEX input component; IDENTIFIER3 is the name of an input component in table template it contains

CMS_INPUT_LINK

IDENTIFIER.text

Outputs the link text of the link created using CMS_INPUT_LINK

CMS_INCLUDE_OPTIONS
in conjunction with

  • CMS_INPUT_CHECKBOX
  • CMS_INPUT_COMBOBOX
  • CMS_INPUT_LIST
  • CMS_INPUT_RADIOBUTTON

In conjunction with CMS_INCLUDE_OPTIONS, the examples above apply in principle to the aforementioned input components.

For a checkbox with CMS_INCLUDE_OPTIONS, e.g.,:
BEZ.map(x->x.value.value("BEZ2")).toString(", ")

If using the Database type, see also section Using labels from (referenced) tables ("label").

 

FS_REFERENCE
("Image" or "File" object type)

IDENTIFIER.Media.Filename

Outputs the reference name of the image / file referenced using FS_REFERENCE

FS_REFERENCE
("Page reference" object type)

IDENTIFIER.pageRef.uid

Outputs the reference name of the page reference referenced using FS_REFERENCE

IDENTIFIER.pageRef.page.formData.IDENTIFIER2

Outputs the input component content with the IDENTIFIER2 identifier, which is included in the page (Page Store) for the page reference selected using FS_REFERENCE

   
Important The use of objects of Entity data type is not supported in snippets.

Shortening and formatting

By default, if nothing else is specified, all of the content in the “Label” and “Extract” fields is output from the specified input component. Therefore, we recommend, if possible, limiting the number of characters for text input components (e.g., using maxInputLength or maxCharacters; see, for example, CMS_INPUT_TEXT).

Alternatively, the truncate parameter can be used to specify how many characters are to be displayed. If the text saved in the input component has more characters than those specified by truncate, three periods (...) are appended to the output.

truncate(IDENTIFIER, 25)

This specification shortens the text output of the input component with the identifier IDENTIFIER to 25 characters.

Text can be output in bold or italics using the bold(IDENTIFIER) and italic(IDENTIFIER) parameters. The bold parameter has no effect in the “Label” field since the title for output text is generally shown in bold.

Example

italic(truncate(if(!pt_headline.isEmpty, pt_headline), 30) +
if(!pt_headline.isEmpty && !pt_subheadline.isEmpty, " / ") +
truncate(if(!pt_subheadline.isEmpty, pt_subheadline), 15))

In this case, the content of the input components pt_headline and pt_subheadline are output in italics (if they are not empty), separated by a slash with spaces:

FirstSpirit Hybrid CMS / Agility enabled by the FirstSpirit Hybrid CMS

Depending on the respective object type, methods can be used to provide additional formatting in addition to these general attributes. The following table lists example formatting options for some input components:

Formatting

Parameter / Method

Input component

Bold

bold(IDENTIFIER)

 

Italics

italic(IDENTIFIER)

 

Truncating

truncate(IDENTIFIER, NUMBER)

 

Upper / lower case

toUpperCase / upperCase
toLowerCase / lowerCase

CMS_INPUT_TEXT
CMS_INPUT_TEXTAREA

Number / date format

format

CMS_INPUT_DATE
CMS_INPUT_NUMBER

   

Displays the dataset ID.

In the case of datasets, the dataset ID can also be used for snippet display by entering the

#id

Within the relevant table template, a snippet definition for press releases, including the relevant dataset ID, might look like this:

Label:

"Press release " + italic(#id)

Using labels from (referenced) tables ("label")

If values from a (referenced) table are selectable using CMS_INCLUDE_OPTIONS in CMS_INPUT_COMBOBOX, for instance, the identifier that originated from the (referenced) table can be displayed in the search result using label(#language). (For information on #language / #global.language, refer to this page.)

Form A example

<CMS_INPUT_TEXT name="cs_branch" singleLine="no" useLanguages="no">
<LANGINFOS>
<LANGINFO lang="*" label="City"/>
<LANGINFO lang="DE" label="Stadt"/>
</LANGINFOS>
</CMS_INPUT_TEXT>

<CMS_INPUT_COMBOBOX name="cs_country_choice" singleLine="no" useLanguages="no">
<CMS_INCLUDE_OPTIONS type="database">
<LABELS>
<LABEL lang="*">#item.Name</LABEL>
</LABELS>
<TABLE>country</TABLE>
</CMS_INCLUDE_OPTIONS>
<LANGINFOS>
<LANGINFO lang="*" label="Country"/>
<LANGINFO lang="DE" label="Land"/>
</LANGINFOS>
</CMS_INPUT_COMBOBOX>

Where country is a referenced table (see below). City names are saved via cs_branch; a country is selected from the referenced table using the cs_country_choice combo box.

Form B example (country table)

<CMS_INPUT_TEXT name="cs_country" singleLine="no" useLanguages="yes">
<LANGINFOS>
<LANGINFO lang="*" label="Country"/>
<LANGINFO lang="DE" label="Land"/>
</LANGINFOS>
</CMS_INPUT_TEXT>

Country names are saved under cs_country (Name column).

Snippet example

if(!cs_country_choice.isEmpty, cs_country_choice.label(#language))

With this expression, the text saved in the Name column of Form B for the selected entry is shown as a result when searching for a value that has been selected using the combo box with the identifier cs_country_choice in Form A.

If, for example, the value “Dortmund” is selected for cs_branch in Form A and the value “Germany” is selected via cs_country_choice, the value “Germany” can be displayed as the text excerpt for a search for “Dortmund” instead of the name from data source B.

Outputting of UID, display name or GID via #item

The #item object is available on the “Snippet” tab in the fields “Label” and “Extract”. It returns the respective tree element. Object-specific methods from the interface IDProvider (FirstSpirit Access API, package de.espirit.firstspirit.access.store) can in turn be applied to this.

Note: The #item object is not available in the data type Card.

Important In exceptional cases, for example when creating objects, #item is not available and a warning of the type java.lang.UnsupportedOperationException or java.lang.RuntimeException will be logged (Expression failed). This should be taken into account during template development.

Outputting UID or display name

#item.getDisplayName(#language)

Outputs the display name of the respective object in the respective language.

#item.Uid 

Outputs the UID of the respective object.

#item.getDisplayName(#language) 
"[UID:" + " " +italic(#item.getUid) + "]"

Outputting the GID (Datasets)

If the tree element contains further FirstSpirit objects in the form of datasets (e.g. FS_INDEX with a DatasetDataAccessPlugin), the GID (Global ID) of the datasets can be accessed via #item.

The GID of a dataset can be specified using:

#item.getEntity().getGid() 

Outputting the current date via #now

The #now object returns the current date at the time of the query.

"valid " + if(cs_newsdate > #now,"from ","since ") + cs_newsdate.format("MM/dd/yy") 

Compares the current date with the date from an input component CMS_INPUT_DATE.

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