Creating a Sitemap As a Table of Contents

A sitemap is understood to be a depiction of the hierarchy of a website or a part of this hierarchy, whereby ideally the elements of this depiction are linked with the corresponding web pages. You can use the mechanisms for automatically generating tables of contents to create a sitemap with CMS Fiona. In contrast to the Examples of Automatically Generated Tables of Contents, however, for a sitemap the table of contents must be generated up to the last hierarchy level.

This can be achieved by generating the table of contents in a layout that always calls itself if it encounters a subfolder when creating the table of contents. The process of calling itself is called recursion.

In the following example the entries are indented by ul elements nested within each other. Additional means of entry identification (e.g. with a type-dependant icon for the displayed file) are left out.

<ul>
  <npsobj list="toclist">
    <npsobj name1="objType" value2="generic" condition="isNotEqual">
      <li>
        <npsobj name="self" insertvalue="anchor">
          <npsobj name="title" insertvalue="var"/>
        </npsobj>
        <npsobj name="toclist" condition="isNotEmpty">
          <npsobj name="sitemaptemplate" insertvalue="template"/>
        </npsobj>
      </li>
    </npsobj>
  </npsobj>
</ul>

To create a sitemap using the above sample code, first create a layout file in the base folder with the name sitemaptemplate. Then edit the main content of the draft version with the text editor and insert the above code. Release the layout.

Finally switch to the base folder, open the main content of its draft version with the text editor and insert the following line:

<npsobj name="sitemaptemplate" insertvalue="template"/>

If you now open the preview of the folder the sitemap will be displayed.

Please note that NPSOBJ instructions should normally not be put into the body of folders and documents but into layouts only. This is to ensure that the website remains serviceable.