includePage

Task

This element is replaced with the parsed contents of the referenced page if the current user is permitted to access the page. Otherwise, the element is ignored. To avoid endless recursions resulting from cyclic insertions, the maximum nesting depth is limited to 100.

Syntax

<npspm includePage="path" />

As path an internal path needs to be specified. This path is required to point to a file of the document or publication (folder) type. The element has no content.

If the page with the specified path contains internal links, these links might no longer point to the desired target after the page has been included. The reason for this is that paths in links are relative. If, for example, page C is included in A and B, and B is located in a different folder than A, C would have to be relative to two locations in the folder hierarchy to point to the same location.

This effect can be avoided by using absolute links in included files. However, links with different prefixes are required for the preview and the live server.

This can be solved by means of velocity code, which is evaluated at runtime. The $document tool provides the getUrl method which adds the required prefix to an absolute path and converts the result into an URL. The following example illustrates this by means of a list of links that are created using a toclist. The code that generates the URL is first stored in an export variable whose value is then retrieved by means of an @ reference as the href attribute value:

<npsobj list="toclist">
  <npsobj modifyvar="set" name="robustPath">$document.getUrl(
    <npsobj insertvalue="var" name="visiblePath"/>
  )</npsobj>
  <a href="@robustPath"><npsobj insertvalue="var" name="title"/></a>
</npsobj>

This code causes the absolute Path of the link target (which refers to the folder hierarchy) to be retrieved at runtime and complemeted with code which converts the path to the correct URL.

Example

<npspm includePage="/intranet/docs/public/apps" />