Linking Sibling Files

Sometimes it is convenient to be able to access – apart from the content of a file – also the list of all other files contained in the same folder, i. e. the sibling files.

This can be achieved by means of the following NPSOBJ code that can be inserted into a layout file. The code first sets the current context to the folder containing the current file using list="parent". In this context a toclist is generated that contains all the files in the folder including the current document. By means of a comparison the current document is skipped so that only the sibling files are left over. The comparison refers to the name of the originally exported file and the file currently processed in the toclist. The original file is addressed using context.context. Inside a list, context jumps one level upwards, i. e. to the folder from which the list was generated.

<!-- Set context to folder containing the current document -->
<npsobj list="parent">
  <ul>
  <!-- Create toclist here -->
  <npsobj list="toclist">
    <!-- Take only documents into account  -->
    <npsobj name1="objClass" value2="doc" condition="isEqual">
      <!-- Skip current document using a name comparison. -->
      <npsobj name1="name" name2="context.context.name" condition="isNotEqual">
        <!-- If the name of the originally exported file is different from -->
        <!-- the name of the current toclist entry, a link is output. -->
        <li>
        <npsobj insertvalue="anchor" name="self">
          <npsobj name="title" insertvalue="var" />
        </npsobj>
        </li>
      </npsobj>
    </npsobj>
  </npsobj>
</ul>
</npsobj>