- Created by Robert Reiner, last modified on 15. Jul 2019
projectdoc Toolbox
A collection of macros supports dynamic parameters that may be controlled remotely or by their context. This tip provides some information on context controlled macros.
- Audience
- Type
- Level of Experience
- Expected Duration
- 5 min
A collection of macros of the projectdoc Toolbox for Confluence support dynamic parameters. These parameters may be overridden by a remote call (Remote Controlled Document) or by the context (Context Controlled Macros). The context is defined by the document properties, the properties of all parent documents, and the space properties (including the delegate space closure). Macros need to support this feature. Therefore template author need to provide this feature in their templates. Authors need to know how they can provide properties to change the default behavior of the macro as defined by the template author.
This short tip introduces to this feature, introduced with version 3.1 of the projectdoc Toolbox, by a little example.
Summary
To use context controlled macros you need to provide
- an identifier and
- check the checkbox parameter Context controlled.
Add a property with format identifier:parameter-name
to the context. Set the value for the property.
Macros
The following macros support dynamic properties to be controlled by the context they are in.
- Display List Macro
- Lists references to projectdoc documents in a list. List contain names and optional short descriptions.
- Display List Template Macro
- Lists references to projectdoc documents in a list. List items are defined by templates referencing properties.
- Display Table Macro
- Lists references to projectdoc documents in a table. Allows to select document properties for columns. Also non-list representations are provided.
- Index Entries Table Macro
- Renders a table of index entries.
- Tour-by-Property Macro
- Renders a predefined list of documents in a table . Documents are selected by a document property. Allows to select document properties for columns. Also non-list representations are provided.
- Transclude Documents Macro
- Renders transcluded content fetched from documents of a result set.
- Transclusion Macro
- Transcludes content from a document marked with the content marker macro.
- Transclusion Reference Macro
- Transcludes content via a reference from a document marked with the content marker macro.
- Transclusion to Text Macro
- Transcludes content from a document marked with the content marker macro and renders it as plain text.
A macro is in the context of
- its document,
- the parent documents (up to the root),
- the space the document is part of and
- all spaces in the delegate closure (using the Delegate Space property) of that space.
Templates
To control the parameters with the context, the macro is required to provide a unique identifier.
The feature must be activated. Otherwise the context is not taken into account.
Override Parameter
The parameter's name can be quickly fetched with the inspect context menu item provided by your browser.
Use the part after the prefix "macro-param-
", such as "select
" in the example above.
The name of the parameters that are actually supported are documented with the macro. For the Display Table Macro they are listed with the section Remote Controlled Documents.
Construct the name of the property to override the parameter value like this:
<Macro Identifier> + ':' + <Parameter Name>
For the example above this would read:
myUniqueId:select
Example
In this example we use the Display Table Macro to list documents that describe doctypes. It shows how a basic configuration can be overriden by a context property.
The macro editor shows the Display Table Macro querying for documents of document type 'doctype'. The table columns show the name and the short description for each hit.
To make the macro context aware, we provide an identifier and activate the Context controlled checkbox.
Now add the property to the document that contains the macro.
The table will now be rendered with columns Name, ID, Set, and Short Description.
Resources
- Context Controlled Macros
- A context controlled macro uses properties from its context to control the content being rendered. This includes document and space properties.
- Display Table Macro
- Lists references to projectdoc documents in a table. Allows to select document properties for columns. Also non-list representations are provided.
- Delegate Space
- Delegate spaces help to organize information that is used by more than one space. Resources may be delegated to other spaces. This includes the definition of space properties and providing homepages for documents of a given type.
- Space Property
- A property defined on the space homepage that takes effect on the space and delegating spaces.
- Document Property
- A property is metadata for a document. It has name, a value, and a control (such as hide).