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

#fs_catalog

The system object #fs_catalog is available in the templates which are used by elements of a FS_CATALOG input component. In other words: if a section or link in an FS_CATALOG input component is rendered the system object is available in the referenced section or link template.

If #fs_catalog is used in a template and this is rendered outside of FS_CATALOG the return is null. In addition, an error is displayed in the preview/generation log. Therefore it is recommended, before using the system object #fs_catalog, to check whether it is null or not:

$CMS_IF(!#fs_catalog.isNull)$
...
$CMS_END_IF$

The two intended uses of #fs_catalog are:

  1. Determination whether the rendered element is located in an FS_CATALOG or not
  2. Determine the number of elements contained in an FS_CATALOG

Important The invocation of $CMS_VALUE(#fs_catalog) (without method invocation) results in an endless loop which is logged in the preview/generation log (ERROR: endless loop in template?).
Important The system object #fs_catalog is not available for the output of an FS_CATALOG input component with a $CMS_FOR(...)$ instruction! The output of the number of elements in the input component can however also be realised in the instruction with .size:
$CMS_FOR(card, st_catalog)$
$CMS_VALUE(#for.index + 1)$/$CMS_VALUE(st_catalog.size)$: $CMS_VALUE(card)$
$CMS_END_FOR$

The individual invocations and their meaning:

Invocation

Meaning

Return data type

#fs_catalog.isNull

Is the element just rendered part of an FS_CATALOG input component or not.
true: the element is not part of an FS_CATALOG input component.
false: the element is part of an FS_CATALOG input component.

Boolean
(Boolean value)

#fs_catalog.size

Number of elements in an FS_CATALOG input component.

Integer

   

Examples of #fs_catalog

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: Numbered output of sections

Definition of the FS_CATALOG input component (form):

<CMS_MODULE>
<FS_CATALOG name="st_catalog">
<LANGINFOS>
<LANGINFO lang="*" label="Section list"/>
</LANGINFOS>
<TEMPLATES type="section">
<TEMPLATE uid="text"/>
</TEMPLATES>
</FS_CATALOG>
</CMS_MODULE>

Invocation of the input component (HTML template set):

$CMS_VALUE(st_catalog)$

Definition of the section template (“text”, form):

<CMS_MODULE>
<CMS_INPUT_TEXT name="st_text">
<LANGINFOS>
<LANGINFO lang="*" label="Text"/>
</LANGINFOS>
</CMS_INPUT_TEXT>
</CMS_MODULE>

Numbered output in the section template (HTML template set):

<CMS_HEADER />
$CMS_IF(!#index.isNull && !#fs_catalog.size.isNull)$
$CMS_VALUE(#index + 1)$/$CMS_VALUE(#fs_catalog.size)$:
$CMS_END_IF$
$CMS_VALUE(st_text)$
<br>

Apart from the value of the text input component the example also outputs the index (increased by one) and the total number of sections (e.g. “1/3”).

Output:

1/3: 1st Section
2/3: 2nd Section
3/3: 3rd Section

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