Document structure variable - Fluid Topics - Latest

Fluid Topics Configuration and Administration Guide

Category
Reference Guides
Audience
public
Version
Latest

The $structuredTopics variable contains a JSON object with a representation of the document's structure.

It contains the following keys:

Key Description
title The title of a topic.
depth The table of content depth of a topic. 1 is a root-level topic.
htmlContent The HTML content of a topic.
breadcrumb The parent topics of a topic.
officialReaderUrl The URL of the topic on the portal.
topicSourceType Can be OFFICIAL, or PERSONAL for a topic written in a personal book.
confidential true if a topic belongs to a document for which the Add to personal book feature is disabled.
originContentId The Content ID of the topic.
originTocId When printing personal books only, the ToC ID value of the topic.
originMapId When printing personal books only, the Document ID value of the parent document of the topic.

For example:

[
  {
    "title": "Knowledge Hub web services for administrators",
    "depth": 1,
    "htmlContent": "<p>This section describes web services with routes beginning as follows:</p>",
    "breadcrumb": [],
    "officialReaderUrl": "https://doc.fluidtopics.com/r/Fluid-Topics-API-Reference-Guide/Knowledge-Hub-web-services-for-administrators",
    "topicSourceType": "OFFICIAL",
    "confidential": false,
    "originContentId": "OcFYGd01lcsA7VA3Fa4MMg",
    "originTocId": "",
    "originMapId": ""
  },
  {
    "title": "Maps",
    "depth": 2,
    "htmlContent": "<p>This section explains how to use Fluid Topics web services to manage a portal's maps (structured documents).</p>",
    "breadcrumb": [
      {
        "title": "Knowledge Hub web services for administrators",
        "officialReaderUrl": "https://doc.fluidtopics.com/r/Fluid-Topics-API-Reference-Guide/Knowledge-Hub-web-services-for-administrators",
        "topicSourceType": "OFFICIAL"
      }
    ],
    "officialReaderUrl": "https://doc.fluidtopics.com/r/Fluid-Topics-API-Reference-Guide/Knowledge-Hub-web-services-for-administrators/Maps",
    "topicSourceType": "OFFICIAL",
    "confidential": false,
    "originContentId": "OcFYGd01lcsA7VA3Fa4MMg",
    "originTocId": "",
    "originMapId": ""
  },
  {
    "title": "Delete a map attachment",
    "depth": 3,
    "htmlContent": "<p>This web service deletes an attachment from publications based on a metadata selection.</p>",
    "breadcrumb": [
      {
        "title": "Knowledge Hub web services for administrators",
        "officialReaderUrl": "https://doc.fluidtopics.com/r/Fluid-Topics-API-Reference-Guide/Knowledge-Hub-web-services-for-administrators",
        "topicSourceType": "OFFICIAL"
      },
      {
        "title": "Maps",
        "officialReaderUrl": "https://doc.fluidtopics.com/r/Fluid-Topics-API-Reference-Guide/Knowledge-Hub-web-services-for-administrators/Maps",
        "topicSourceType": "OFFICIAL"
      }
    ],
    "officialReaderUrl": "https://doc.fluidtopics.com/r/Fluid-Topics-API-Reference-Guide/Knowledge-Hub-web-services-for-administrators/Maps/Delete-a-map-attachment",
    "topicSourceType": "OFFICIAL",
    "confidential": false,
    "originContentId": "OcFYGd01lcsA7VA3Fa4MMg",
    "originTocId": "",
    "originMapId": ""
  }
]

The value of each htmlContent key has been shortened to enhance readability.

Use case:

The $structuredTopics variable allows for greater control on the layout of PDFs.

The following Velocity code sample uses the $structuredTopics variable to:

  1. Create titles for each topic found in the $structuredTopics variable, taking into account the depth of the topic;
  2. Create a breadcrumb below the title of topics, if the topic is not a top-level topic;
  3. Insert the content of the topic.

In this situation, the $structuredTopics variable replaces the $topics variable, adding a breadcrumb after the title of topics.

#foreach ($structuredTopic in $structuredTopics)

    <!-- Titles -->
    #set ($depthClass = "pdf-header-lvl" + $structuredTopic.depth())
    #if ($structuredTopic.depth() >= 1 && $structuredTopic.depth() <= 6)
        <h$structuredTopic.depth() class="$depthClass">$structuredTopic.title()</h$structuredTopic.depth()>
    #else
        <h6 class="$depthClass">$structuredTopic.title()</h6>
    #end

    <!-- Breadcrumb -->
    #if ($structuredTopic.breadcrumb().size() > 0)
        <div class="breadcrumb">
            <strong>Navigation</strong>:
            #foreach ($item in $structuredTopic.breadcrumb())
                <span>$item.title() /</span> 
            #end
            <em>$structuredTopic.title()</em>
        </div>
    #end

    <!-- Topic content -->
    <p>$structuredTopic.htmlContent()</p>

#end

It has a breadcrumb CSS class containing the following styles:

.breadcrumb {
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
}

The previous code creates the following layout:

A topic containing a navigation breadcrumb after its title. The breadcrumb begins by the word 'Navigation:' followed by the title of the parent topic of the topic, and the title of the topic in italics.