Snippets
For some template types, how FirstSpirit objects based on those templates (e.g. pages, sections, data records) are to be displayed at some places in JavaClient and WebClient can be specified using the “Snippet” tab. The variable names for input components on the template are referenced for this. This representation is used in both JavaClient and WebClient, for example for search results.
The goal is not just to display FirstSpirit objects with names (i.e., depending on the hit, the page name, section name, data record ID, etc.), but rather mirroring the respective object as accurately as possible using:
- an image (field “Thumbnail” on the “Snippet” tab),
- a title (field “Label” on the “Snippet” tab) and
- a text excerpt (field “Extract” on the “Snippet” tab).
This way, the editor is able to receive a clear presentation of the content of the search hit in order to determine the most relevant hit more easily and to get to the object being searched for more quickly.
As many characters as needed can be entered in the fields on the “Snippet” tab. If more characters are present than the text field can take on, the text field is provided with a vertical scroll bar.
It is conceivable that, instead of just using input components whose content will later be used in the presentation channels, special input components may be defined in the forms where editors could store descriptive text, keywords and other information that is only intended for output within the project and not for output on the website.
The following figure shows a search result in JavaClient and in WebClient:
Flexible output
Multiple input components can be combined in order to be able to better adjust the output to the needs of the respective project and editors. In addition, methods that can be used with $CMS_VALUE(...)$ can be implemented. This way, the use of entered editorial content for searching can be made to depend on the inputs. If an input component specified on the “Snippet” tab has not been filled by an editor, the name is shown as the title (Label) and the path to the search hit is shown as a text excerpt (Extract) by default. The path is shown independently in every case in WebClient. Therefore, it is recommended that the object first should be checked to determine whether it is empty ( .isEmpty() method).
Image (Thumbnail)
The input component that is to be used for the search result image can be defined using this field.
This image appears on the right edge of a search hit.
The following input components are available for referencing images, for example:
- FS_REFERENCE
- CMS_INPUT_PICTURE (deprecated)
- CMS_INPUT_IMAGEMAP
If there no input component is present in the template for selecting an image or if no image is to be displayed in the search result display, the field can be left empty.
Examples
st_picture
The image from the st_picture input component is used for the search result display.
if(!st_picture.isEmpty, st_picture, st_imagemap)
If the input component with the st_picture identifier is filled, the image from this input component is used for the search result; otherwise the image from the st_imagemap input component is used.
Alternatively, an image can be specified statically from the Media Store using
medium("REFERENCENAME")
or, for short,
"REFERENCENAME"
where the placeholder REFERENCENAME has to be the reference name for the image to be displayed.
Images from remote projects
Images from remote projects can be implemented using
medium("REFERENCENAME", "REMOTEPROJECTNAME")
where the placeholder REMOTEPROJECTNAME has to be the symbolic name of the desired remote project.
Images from data records
Furthermore, images from data records can also be used, such as those that have been embedded using FS_DATASET.
The use of objects of the Entity data type is not supported in snippets! |
Instead of that, the .getFormData() method should be used, e.g.
if(!pt_product.isEmpty, pt_product.dataset.formData.cs_picture)
where pt_product is the identifier for the FS_DATASET input component used to select a data record with an image, and cs_picture is the identifier of an input component in the table template where the image is saved.
Title and text excerpt (Label and Extract)
Using the
- “Label” field, an input component that is to be used for the title of the search result can be specified.
In WebClient, the name of the table template is displayed in front of the content of the title in the title of data records, e.g.:
Press releases: [30.12.2012] Mithras Energy receives solar prize from the City of Sonningen. - “Extract” field, the input component that is to be used for the text excerpt of the search result can be specified.
The content is output by specifying a variable name from 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.
Example for the output of content from CMS_INPUT_DOM:
IDENTIFIER.toText(false)
There, IDENTIFIER is the variable name for an input component of CMS_INPUT_DOM type.
Examples for output
The following table lists examples of output options for some input components:
Input component | Output via | Note |
---|---|---|
IDENTIFIER | outputs the value defined using ENTRY / name | |
IDENTIFIER.toText(false) | ||
CMS_INPUT_FILE | IDENTIFIER.element.uid | outputs the reference name of the file referenced using CMS_INPUT_FILE |
IDENTIFIER.text | outputs the link text of the link created using CMS_INPUT_LINK | |
FS_LIST (INLINE type) | IDENTIFIER.map(x | IDENTIFIER2 is a variable name for a section template selected using FS_LIST |
FS_LIST (DATABASE type) | IDENTIFIER.map(x | IDENTIFIER2 is a variable name for a table template referenced using FS_LIST |
IDENTIFIER.dataset.formData.IDENTIFIER2 | IDENTIFIER2 is a variable name for a data record selected using FS_DATASET | |
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 |
CMS_INCLUDE_OPTIONS (DATABASE type) | IDENTIFIER.label(#language) | outputs the value of a selected entry (see the #language section) |
The use of objects of Entity data type is not supported in snippets. |
Multiple input components can be linked using a plus sign (+).
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: " ").
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). Alternatively, the truncate parameter can be used. It can be used to specify how many characters are to be displayed. If the input number is exceeded, three periods (...) are appended to the output.
truncate(IDENTIFIER, 25)
This specification shortens the text 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 always 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:
Willkommen bei Mithras Energy / Wo die Sonne z...
Depending on the respective object type, methods can be carried out, which can be used to provide additional formating in addition to these general attributes. The following table lists, for instance, formatting options for some input components:
Formatting | Parameter/Method | Input component |
---|---|---|
bold | bold(IDENTIFIER) | |
italics | italic(IDENTIFIER) | |
Truncating | truncate(IDENTIFIER, NUMBER) | |
Upper/lower case | ||
Number/date format | ||
#language
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).
Table A form 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.
Table B form example (country, referenced 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 Table B's Name 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 Table A.
If, for example, the value “Dortmund” is selected for cs_branch in Table 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.
Preview
A direct preview of the search result display can be obtained in the integrated preview using the "Snippet" tab. A preview page has to be selected on the "Properties" tab for this.
Effects in WebClient
In WebClient, the definitions on the "Snippet" tab are also used for displaying search results. Furthermore, they are also used:
- for selecting templates (creating new pages, sections and data records, selecting internal references)
- for the display in search dialogs
- for the report area:
- Global search
- Bookmarks
- Tasks
- Related elements
- My changes