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

Example: form for external links

External links refer to objects outside of the FirstSpirit project, such as pages on other Internet sites.

The following shows an example of a form and the syntax for the corresponding output for a link that leads to the start page of the company website www.e-Spirit.com.

Display (SiteArchitect)

Dialog external link

Explanation

 

Use

Input component in the following code example

1.

Input of the link target in a valid format (e.g. http://www.e-spirit.com).
(Mandatory field, see Introduction)

lt_reference

2.

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

lt_text

3.

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

lt_comment

4.

Selection of a target window (Should the link target open in the same window, in a new window, or in a defined window specific to the project?). By default, link targets open in the same window. Links to external websites should ideally open in a new window.

lt_target

   

Form

<CMS_MODULE>

<CMS_INPUT_TEXT name="lt_reference" hFill="yes" singleLine="no" useLanguages="no">
<LANGINFOS>
<LANGINFO lang="*" label="Target URL"/>
<LANGINFO lang="DE" label="Zieladresse"/>
</LANGINFOS>
</CMS_INPUT_TEXT>

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

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

<CMS_INPUT_COMBOBOX name="lt_target" hFill="yes" singleLine="no" useLanguages="no">
<ENTRIES>
<ENTRY value="_blank">
<LANGINFOS>
<LANGINFO lang="*" label="in new window"/>
<LANGINFO lang="DE" label="in neuem Fenster"/>
</LANGINFOS>
</ENTRY>
<ENTRY value="_self">
<LANGINFOS>
<LANGINFO lang="*" label="in current window"/>
<LANGINFO lang="DE" label="im aktuellen Fenster"/>
</LANGINFOS>
</ENTRY>
</ENTRIES>
<LANGINFOS>
<LANGINFO lang="*" label="Target window"/>
<LANGINFO lang="DE" label="Zielfenster"/>
</LANGINFOS>
</CMS_INPUT_COMBOBOX>

</CMS_MODULE>

Output

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_VALUE(lt_reference)$">$CMS_VALUE(lt_text)$</a>

Dynamic forms are used to check whether the format of the editor's link target input is valid.

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 time window selected by the editor using lt_target can be output and taking into account. The getKey method is used to do this (for more information, see option data type). The determined value is used for the target HTML attribute. This attributes expects _blank (to open the link in a new window) or _self (to open the link in the same window), for instance, as the value. The editor selects values using the relevant combo box in the form.

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

<a href="$CMS_VALUE(lt_reference)$"

title="$CMS_VALUE(lt_comment)$"
target="$CMS_VALUE(lt_target.getKey())$"
>
$CMS_VALUE(lt_text)$
</a>

Schema

External link input and output
 

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