Link collections usually consist of linked texts. Within an NPSOBJ-list
or NPSOBJ-table
instruction you can create a hyperlink for each free link in the list by means of an NPSOBJ-insertvalue
instruction. The link destination is available to you as the value of the destinationUrl
parameter. As linked text you can use the link title (displayTitle
) as shown in the following example:
<ul> <npsobj list="relatedLinks"> <li> <npsobj name="destinationUrl" insertvalue="anchor"> <npsobj name="displayTitle" insertvalue="var"/> </npsobj> </li> </npsobj> </ul>
You can specify the title of a free link as you create or edit the link.
In the example shown above, the link collection is formatted as an unordered list. However, you can use any HTML code for styling your list.
In link collections it is not only possible to access the URL of the link destination. If the link destination is a file you have full access to this file and can use its title as linked text, for example. You can access a field of the destination file by using the destination
link parameter followed by the name of the desired field. Separate the two elements by a period. In the following example the value of the custom field abstract
is queried:
<npsobj name="destination.abstract" insertvalue="var"/>
In this way, for your link collections, you can use any desired piece of information available in the destination file. The following sample code generates a link collection consisting of the titles and the creation dates of the destination files. The titles are linked with the destination files:
<ul> <npsobj list="relatedLinks"> <li> <npsobj name="destinationUrl" insertvalue="anchor"> <npsobj name="destination.title" insertvalue="var"/> </npsobj><br> <npsobj name="destination.lastChanged" insertvalue="var"/> </li> </npsobj> </ul>
In link collections you can use the same mechanisms as in tables of contents to restrict the lists to particular entries (see section Controlling Entries). If, for example, only links to files located in or below the /documents/public/
folder are to be included in the list you can achieve this with an NPSOBJ-condition
instruction.
<ul> <npsobj list="relatedLinks"> <npsobj name1="destination.prefixPath" value2="/documents/public/" condition="hasPrefix"> <li> <npsobj name="destinationUrl" insertvalue="anchor"> <npsobj name="destination.title" insertvalue="var"/> </npsobj> </li> </npsobj> </npsobj> </ul>
It is also possible to sort the links in a link list according to particular field values of the target files by specifying the sortkey1
attribute in the NPSOBJ-list or NPSOBJ-table
tag in order do determine the primary sort criterion. For example, in order to sort the elements by the date they were last changed you can use the following code:
<npsobj list="relatedLinks" sortkey1="destination.lastChanged"> ... </npsobj>
Analogous to the first criterion, the second and the third criterion can be specified using sortkey2
and sortkey3
, respectively.