Document structure variable - Fluid Topics - 4.3

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:

  • 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.

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"
        }, 
        {
            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"
        }, 
        {
            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"
        }
    ]
}

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: