Start page / Templates (basics) / Composition of templates / Link templates / Examples / Internal links

Example: form for internal links

Internal links refer to objects within the current project, such as pages/references, media or datasets, thus fulfilling a standard requirement in web projects: the linking of objects within a project.

The following shows an example of a form and the syntax for corresponding output for a link that leads to a different page in the project and, if necessary, to a section of that page.

Display (SiteArchitect)

Dialog internal link




Input component in the following code example


Selection of a page from the site store and, if applicable, of a section on this page to which the link leads when the user clicks on it.
(Mandatory field, see Introduction)



Input of a link text.
(Mandatory field, see Introduction)



Input of an optional comment, which can be displayed as a tool tip for the link.



Selection of the language version in which the page is to be opened. This enables linking to a page in another language version, for instance, if the page does not yet exist in the language of the output page.





<FS_REFERENCE name="lt_reference" hFill="yes" useLanguages="no">
<ALLOW type="pageref"/>
<LANGINFO lang="*" label="Target"/>
<LANGINFO lang="DE" label="Ziel"/>
<LOCAL name=".">
<FOLDER name="root" store="sitestore"/>

<CMS_INPUT_TEXT name="lt_text" hFill="yes" singleLine="no" useLanguages="no">
<LANGINFO lang="*" label="Link text"/>
<LANGINFO lang="DE" label="Verweistext"/>

<CMS_INPUT_TEXT name="lt_comment" hFill="yes" singleLine="no" useLanguages="no">
<LANGINFO lang="*" label="Comment"/>
<LANGINFO lang="DE" label="Kommentar"/>

<CMS_INPUT_COMBOBOX name="lt_language" hFill="yes" singleLine="no" useLanguages="no">
<CMS_INCLUDE_OPTIONS type="language"/>
<LANGINFO lang="*" label="Language"/>
<LANGINFO lang="DE" label="Sprache"/>


Form configuration information:

The lt_reference input component (FS_REFERENCE type) is used with the input of

<ALLOW type="pageref"/>

to select only page references from the current project.


Important The following shows examples of only the minimum amount of code that is needed for suitable adaptation in a production project. Thus, for instance, a Not Empty check (e.g. $CMS_IF(!lt_reference.isEmpty)$ is not performed. Without this check, however, generation errors could occur in the production project.

Links are generally output in HTML using the following syntax:

<a href="[Linktarget]">[Linktext]</a>

The value of lt_reference is used for the link target in the HTML output via the link template. The value of lt_text is used for the link text:

<a href="$CMS_REF(lt_reference)$">$CMS_VALUE(lt_text)$</a>

In order to jump to a section of the page (anchor) selected by the editor, the reference name of the selected section is defined using getSectionName and is output with the # character.

Important To use the anchor functionality in FirstSpirit when using FS_REFERENCE in the desired section templates, the <a> tag needs to be activated in the “File extension” area of the “Properties” tab.

Comments from the lt_comment field can be output as a tool tip for the link using the title HTML attribute.

As the final step, the link target language selected by the editor using lt_language can be output and taken into account. The language attribute is used for resolving the reference (see also $CMS_REF(...)$). This attribute expects a valid language code for the project as the value, such as DE or EN, which is exactly what the editor can specify using the relevant combo box in the form. The selected and saved value can be read out using the getKey method.

A simple example of the link output could ultimately look like the following:

 <a href="$CMS_REF(lt_reference, language:lt_language.getKey())$#$CMS_VALUE(lt_reference.getSectionName())$"


Internal link input and output

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