- Created by Robert Reiner, last modified on 06. Jan 2020
Learn about the central most heavily used macros of your projectdoc Toolbox.
Background Information
The central macros of the projectdoc Toolbox are:
- Document Properties Marker Macro
- A table containing document properties. Three columns: name, value and meta data (aka controls) to a property.
- Section Macro
- Renders a section, if the body is not empty. Supports authors to create content, clutter-free rendering without empty sections. Allows to transclude the content.
- Display Table Macro
- Lists references to projectdoc documents in a table. Allows to select document properties for columns. Also non-list representations are provided.
- Transclusion Macro
- Transcludes content from a document marked with the content marker macro.
Document Properties Marker Macro
The Document Properties Marker Macro contains a three columned table with the document properties. Authors will rarely add this macro to a page since this is the job of the template author.
Nevertheless the author uses the macro by editing existing properties or adding new properties to it.
The three columns contain the
- name,
- the value,
- and controls
of the property. Every property is on its own line.
The most used property control is probably the hide control. It prevents the property from being rendered in the table. You may even opt to hide the whole table with the Hide parameter of the macro.
Section Macro
The Section Macro renders a section with a title and its content. The content is added to the macro's body.
If the content is empty, the section will not be rendered. This macro is an essential element for template authors. The structure of a template for a document type can be defined so that document authors have guidance which information to place where. But as long as no content is provided by the document author, the reader of the document is not distracted by empty sections.
Display Table Macro
With the Display Table Macro document authors display result sets of document queries.This allows to add references to documents on the the wiki that automatically expands when new documents are added that match the given search criteria.
The macro allows to select properties and section from the documents. The search result is filtered by a where clause in Lucene syntax. The macro also allows to sort the result set by properties.
Accessing a single Property
If you only need to access a single property value within text, have a look at the Display Document Property Macro.
Transclusion Macro
The Transclusion Macro includes content from another page at render time. Transclusion supports single sourcing.
The content to be transcluded has to be marked as a section (Section Macro) or region content (Content Marker Macro).
Transclusion only works with plain Confluence pages since version 1.11 of the projectdoc Toolbox.
Before that version only transclusion from projectdoc documents was defined. Creating a projectdoc document is simple: add the Document Properties Marker Macro. No special properties required.
The body provides space for replacements of the form "placeholder=replacement
", each on its own line. Specify a placeholder like this ${placeholderName}
.
Hands-on Steps
Use the Document Properties Marker Macro
- Open the person document from a previous step for editing
- Go to the
Team
property you have added; in the last column type 'hide' - Save the document
The line with the Team
property is no longer shown.
Use the Section Macro
- Open the person document from a previous step
- Add a new Section after the
Description
section called 'Questions
' - Add a section within this section and name it '
Question One
' - Add some lines to the body of the Section Macro
- Add a second section '
Question Two
' as a sibling to the section named 'Question One
' - Do not add text to the body
- Save the document
The section named question and the sibling that contains text is shown. - Open the person document again
- Remove the text from the section named '
Question One
' - Save the document
The question section with its two children contains no text and is therefore not rendered.
Use the Display Table Macro
- To run some tests we add a second person document to the index space
- Click '
Create
' - Put John to his sister's team
- Create a document of type 'Topic' in the '
My Workspace
' space - Send it to its homepage
- Add a new section called '
Members of the Team
' - Add a Display Table Macro to its body
- Select on doctype '
role
' and display three columns:Name
,Short Description
,Team
- Save the macro
- Save the page
The page renders as follows:
- Click on '
John Doe
', edit the page and change the team name to 'True Testers
' - Check the table on the '
My Team
' page - Edit the '
My Team
' page - Add a where clause to the Display Table Macro to select only on the '
JS Smurfs
' team - Save the macro
- Save the page
The constraint 'Team = "JS Smurfs"
' for the Where parameter selects on any sequence that has "JS Smurfs
" in it. To make an exact match, use the following:
$<Team> = [JS Smurfs]
The exact match is typically recommended, but we showed the simplified constraint to introduce the additional syntactic bitterness in a second step.
For more information on searches, please refer to the Search Tips!
The result table contains only one hit.
For more information on search options,visit Search Tips.
Use the Transclusion Macro
- Go to the homepage of '
My Workspace
' - Edit the page
- Add the Transclusion Macro to transclude the section '
Members of the Team
' - Save the macro
- Save the page
Put John to the '
JS Smurfs
' teamIf you lost track of John, find the Person homepage: Go to the index space or your workspace homepage and click the link "
Persons
".- Go to the homepage of '
My Workspace
'
Note that the transclusions are not cached. If they were cached, the result my show a stale fragment. This is due to the fact that dynamic content does not match well with caching. Therefore you should either do not transclude dynamic content or you may select the transclusion to not be cached.
- Go to the homepage of '
My Workspace
' - Edit the page
- Add a section with title '
Test
' - Move the transclusion macro to the body of this new section
- Edit the transclusion macro
- Change the target level to '
*
' - Save the macro
- Save the page
Note that the level of the transcluded section is automatically set to '2
'. The section is originally at level '1
'. We set the target level to '*
' to request projectdoc to calculate the level of the transcluded section automatically to match that of the enclosing section plus one. Note that this feature only works with sections and not with pure headings.
Next Step
Continue with the next step: Categorization