Scenario

We want to create a dynamic table of contact details on a Confluence page while also making it collapsible to to initially hide it from the reader.

This is doable by combining Scaffolding macros with the Cloak and Toggle Cloak macros from Composition Tabs for Confluence Server and Data Center.

Result

Recipe

Apps


Scaffolding, Composition Tabs for Confluence


Platform

Server, Data Center

Level

Easy

Estimated time

10 minutes ⏱

Macros

Number Data, Table Data, Text Data

Storage format

You can copy and paste this code into the Confluence Source Editor:

<h2>
  <ac:structured-macro ac:macro-id="bbed47c1-f02b-4531-8944-7a4ab9ff0fb2" ac:name="toggle-cloak" ac:schema-version="1"/>Contact details</h2>
<ac:structured-macro ac:macro-id="cd833aa7-56ff-46b3-883d-996b6fa8ee0a" ac:name="cloak" ac:schema-version="1">
  <ac:rich-text-body>
    <ac:structured-macro ac:macro-id="921c1933-a9bb-4cf9-b7ce-8eae3a51b415" ac:name="table-data" ac:schema-version="1">
      <ac:parameter ac:name="name">contacts</ac:parameter>
      <ac:rich-text-body>
        <table class="wrapped">
          <colgroup> <col/> <col style="width: 96.0px;"/> <col style="width: 29.0px;"/> <col style="width: 29.0px;"/> <col style="width: 29.0px;"/> </colgroup>
          <tbody>
            <tr>
              <th colspan="1">Job Title</th>
              <th>First Name</th>
              <th>Last Name</th>
              <th>Email</th>
              <th>Tel Number</th>
            </tr>
            <tr>
              <td colspan="1">
                <div class="content-wrapper">
                  <ac:structured-macro ac:macro-id="299f572c-2c1e-4fcb-a721-c4aa449c0072" ac:name="text-data" ac:schema-version="1">
                    <ac:parameter ac:name="name">JobTitle</ac:parameter>
                    <ac:parameter ac:name="type">line</ac:parameter>
                    <ac:parameter ac:name="content">text</ac:parameter>
                    <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
                    <ac:rich-text-body>
                      <p>
                        <br/>
                      </p>
                    </ac:rich-text-body>
                  </ac:structured-macro>
                </div>
              </td>
              <td>
                <div class="content-wrapper">
                  <ac:structured-macro ac:macro-id="a7cc0683-ac16-4a28-83f9-304324f60e5c" ac:name="text-data" ac:schema-version="1">
                    <ac:parameter ac:name="name">FirstName</ac:parameter>
                    <ac:parameter ac:name="type">line</ac:parameter>
                    <ac:parameter ac:name="content">text</ac:parameter>
                    <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
                    <ac:rich-text-body>
                      <p>
                        <br/>
                      </p>
                    </ac:rich-text-body>
                  </ac:structured-macro>
                </div>
              </td>
              <td>
                <div class="content-wrapper">
                  <ac:structured-macro ac:macro-id="32413a25-dadb-49f1-a0fa-31bca073e3c3" ac:name="text-data" ac:schema-version="1">
                    <ac:parameter ac:name="name">LastName</ac:parameter>
                    <ac:parameter ac:name="type">line</ac:parameter>
                    <ac:parameter ac:name="content">text</ac:parameter>
                    <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
                    <ac:rich-text-body>
                      <p>
                        <br/>
                      </p>
                    </ac:rich-text-body>
                  </ac:structured-macro>
                </div>
              </td>
              <td>
                <div class="content-wrapper">
                  <ac:structured-macro ac:macro-id="345e7950-ef89-4722-a27e-62a759be7dc0" ac:name="text-data" ac:schema-version="1">
                    <ac:parameter ac:name="name">Email</ac:parameter>
                    <ac:parameter ac:name="type">line</ac:parameter>
                    <ac:parameter ac:name="content">text</ac:parameter>
                    <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
                    <ac:rich-text-body>
                      <p>
                        <br/>
                      </p>
                    </ac:rich-text-body>
                  </ac:structured-macro>
                </div>
              </td>
              <td>
                <div class="content-wrapper">
                  <ac:structured-macro ac:macro-id="d032452d-91c5-4bf0-8aab-1ad02a268dd4" ac:name="number-data" ac:schema-version="1">
                    <ac:parameter ac:name="name">Phone</ac:parameter>
                    <ac:parameter ac:name="atlassian-macro-output-type">INLINE</ac:parameter>
                  </ac:structured-macro>
                </div>
              </td>
            </tr>
          </tbody>
        </table>
      </ac:rich-text-body>
    </ac:structured-macro>
  </ac:rich-text-body>
</ac:structured-macro>

Macro structure

You can recreate the example in the editor view:

Steps

  1. Create a Toggle Cloak macro.

  2. Right after the Toggle Cloak macro, type in "Contact Details".

  3. Create a Cloak macro.

  4. Within the Cloak macro, create a Table Data macro.
    Enter "contacts" in the Name field.

  5. Within the Table Data macro, create a table like this:



  6. Fill in the table cells with relevant Text Data and Number Data macros, like this:


    For more information, refer to Creating a Dynamic Table.