@ References

@ references enable you to use the values available in contexts as the values of HTML attributes. This can not be achieved by using NPSOBJ instructions in the following way:

<!-- DISALLOWED! -->
<a href="/public/file" title="<npsobj insertvalue="var" name="myField" />">...</a>

Instead, an @ reference can be used for this:

<!-- Up to version 6.7.0 -->
<a href="/public/file" title="@myField">...</a>

<!-- From version 6.7.1 -->
<a href="/public/file" title="@{myField}">...</a>

In @ references, all names are available that can also be used in NPSOBJ insertvalue-var instructions, i. e. the names of fields and export variables, for example.

For @ references the following rules and restrictions apply:

  • @ references are only available in the attribute values of HTML and NPSOBJ tags;

  • Up to version 6.7.0: Only tag attribute values beginning with the @ character and whose second character is an alphanumeric character (0 - 9, a - z, A - Z) or the underscore are recognized as @ references.

    From version 6.7.1: @ references start with an @ character directly followed by the variable name enclosed in braces (see the example above). @ references can be used anywhere inside attribute values. Thus, static and dynamic text can be combined at will in these values.

  • Up to version 6.7.0 only: If the first two characters of a tag attribute value are @ characters, they are converted to a single @ character which is not treated as the beginning of an @ reference.

  • @ references neither work in processing instructions (PHP, JSP, etc.) nor in HTML comments.

  • A substituted @ reference is always a character string or a context.

  • If the value to which an @ reference refers is a list (fields of the multiple selection type or context lists), the | character is used to concatenate the individual list items.

  • When content is imported into the CMS, @ references contained in URI attributes such as href are not taken over into link management.

  • If a value cannot be computed, the @ reference is substituted with the empty string.

  • Compound names such as parent.visiblePath are also supported.

  • @ references are not suited for handling the values of multiple selection fields. For this, formatters should be used.

  • If an @ reference refers to an export variable, the value of the export variable is not processed when the @ reference is evaluated since the export variable has already been processed at the time the export variable was set.

  • @ references contained in link title or target attributes (i. e. in fields such as the main content) have priority over titles or targets that have been set through link management (i. e. via the Content Navigator, for example).

  • @ references that have been entered via link management are not evaluated, meaning that they are exported as string constants. However, when content is imported, this string becomes an @ reference because it is then contained directly in the main content.

Examples

The line breaks and indents in the following examples have been inserted for clarity and need to be removed when this code is used. Otherwise the results produced (URLs) will be defective.

The following code generates part of a URL by combining a field value and static text:

<!-- Up to version 6.7.0 -->
<npsobj modifyvar="set" varname="urlpart">
  <npsobj insertvalue="var" name="varname" />?print=YES
</npsobj>
<a href="@urlpart">...</a>

<!-- From version 6.7.1 -->
<a href="@{varname}?print=YES">...</a>

The following code generates an URL which depends on the result of a conditional evaluation:

<npsobj modifyvar="set" varname="yesOrNo">
  <npsobj condition="isEqual" name1="z" value2="1">yesUrl</npsobj>
  <npsobj condition="isEqual" name1="z" value2="0">noURL</npsobj>
</npsobj>

<!-- Up to version 6.7.0 -->
<a href="@yesOrNo">...</a>

<!-- From version 6.7.1 -->
<a href="@{yesOrNo}">...</a>