#global and meta information
Meta information can be deposited on the nodes within the individual stores.
To access this information, the .meta() method is available, which can be invoked on a node. Prerequisite for the invocation is therefore a node from the store. There are two options of obtaining such a node:
- The function ref(): Returns the node on the basis of its reference name
- The system object #global: Returns the current node (see also Page-related #global invocations)
#global can, among other things, return the following objects or nodes:
- #global.node: Page, page reference, document groups
- #global.page: Page
- #global.section: Section
The .meta() method can now be invoked on these objects.
Syntax of .meta()
The structure of the .meta() function looks like this:
$CMS_VALUE(OBJECT.meta("IDENTIFIER"))$
$CMS_VALUE(OBJECT.meta("IDENTIFIER", "none"))$
$CMS_VALUE(OBJECT.meta("IDENTIFIER", "inherit"))$
$CMS_VALUE(OBJECT.meta("IDENTIFIER", "add"))$
$CMS_VALUE(OBJECT.meta("IDENTIFIER", "add").toString("SEPARATOR"))$
The .meta() method consists of a mandatory and an optional parameter.
Specification of an identifier (1st parameter) is mandatory - the output type (2nd parameter) is however not mandatory. |
If the output type is not given the method behaves as if the output type has been specified as none.
Identifier
The first parameter of the .meta() method expects the identifier of an input component (name parameter) from the page template used for maintaining meta information.
Definition of a text input component:
<CMS_INPUT_TEXT useLanguages="no" name="meta_text">
<LANGINFOS>
<LANGINFO lang="*" label="Text"/>
<LANGINFOS>
</CMS_INPUT_TEXT>
Output of the meta information of the page in the Page Store:
$CMS_VALUE(#global.page.meta("meta_text"))$
Output of the meta information of the page reference in the Site Store:
$CMS_VALUE(#global.node.meta("meta_text"))$
Output type
There are three different output types of meta information:
- none
- inherit
- add
These output types are used to specify how the hierarchy of the corresponding store is to be taken into account in the determination of the meta information.
none
If none is specified, the given object only is used for the determination of the meta information. If a value was entered in the given input component on this object this value is returned, otherwise null is returned.
inherit
Unlike none if inherit is specified the given object is initially used for the determination. However, if no value is specified in the input component the determination is repeated for each object of the parent chain up to the root of the relevant store. The first value found is returned as the result and the determination is cancelled. If no value is found the return is null.
add
If add is specified, all meta information of the parent chain is returned as a list - beginning with the specified object - up to the root of the relevant store (List<Object>).
This list can be output with the help of the $CMS_FOR(...)$ instruction:
$CMS_FOR(m, #global.node.meta("meta_text", "add"))$
$CMS_IF(!#for.isFirst)$,$CMS_END_IF$$CMS_VALUE(m)$
$CMS_END_FOR$
Alternatively, the list can also be output with the .toString("SEPARATOR") method. As a separator, e.g. ; can be selected.
$CMS_VALUE(#global.node.meta("meta_text", "add").toString("; "))$
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.
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: Output of the meta information from the root up to the page reference
$CMS_VALUE(#global.node.meta("meta_text", "add").reverse.toString(";"))$
In the example all meta information is collated from the current object - a page reference here - up to the root. The .reverse method is then used to reverse the order of the list and to then output the list separated by a ; (.toString(";")).
Exemplary output:
ParentParent;Parent;Node