projectdoc Toolbox

Using document and space properties as variables in the projectdoc Toolbox for Confluence.

Type
Level of Experience
Expected Duration
10 min
Contents

The projectdoc Toolbox for Confluence allows authors to specify properties on the document and space level. These properties can be seen as variables to control the rendering of projectdoc documents and Confluence pages.

This short tip shows you how to do this.

Define a Property

Properties can be define on document and space level.

 

A projectdoc document is a Confluence page with properties defined by the use of the Document Properties Marker Macro.

A document property is define in a table row in the body of a the Document Properties Marker Macro. The name of a property is required to be a simple text string, but the value may also be macro.

Dynamic Values not supported!

 

A dynamic value is a value that is changed at request time. This is opposed to a value that is only changed once a page is saved.

The value of a property should not have a dynamic value since values are used with indexing and will only be updated when the document is saved.

A space property is actually a document property that is defined on the space homepage.

 

For more information on space properties, please refer to the tip Using Space Properties.

Using Properties

A variable has a value that may be changed. Document and space property values can also be changed. The following sections show uses cases where the change of a property value is reflected on a page that refers to it.

A property value may be simply be rendered or control what is rendered.

Property Reference

A property may simply be referenced with a Display Document Property Macro. Whenever the value of the property is changed, the value will change in the page using this macro is rendered.Macro editor view to render a property value.

Allowed as Property Value

 

The macro can also be used as a property values, since a page gets updated whenever a referenced page is.

There is a number of macros that allows user to render property values.

Macro Short Description
Renders the value of a property of a document.
Renders a template with property references.
Displays a document property from a referenced document.
Displays a single property of a document that is referred by a property of another document and concatenates it with the value of a local property.

Authors may also choose to render properties of a list of documents in tabular form using the Tour Macro. Each property is rendered in a column or multiple properties may be rendered in a table cell using a template.

Control Rendering Sections

With document and space properties authors can control whether or not to render a section (using the Section Macro) or a region (using the Content Marker Macro) on a page.

Section is shown if the property with name 'Type' has a value of 'Tip'.

Authors may also check for a property for any value (i.e. require the property not to be empty).

Section is shown if the property with name 'Authorized by' is not an empty value.

The use case for the above example would be to show the section only if the document is authorized by a person. The authorization is provided by adding the name of the person who give the authorization.

Not a Workflow with role-based protection!

 

This use case does not protect the authorization process. Any user with write access to a page may alter any property (remove it or change value).

List Documents

Document properties can be used to control which documents are shown in dynamic list. The Display List Macro and Display Table Macro provide a parameter named Where to specify queries. A Where clause looks like this:

Where clause to filter on documents.

The following shows the same query but with exact match. While the query above will also match types like "Great Tip" and "Lousy Tip", the query below matches only for "Tip".

Exact match query.

Once the value of a property changes, the query will update the results the next time the page with the dynamic list is rendered.

 

For date values there is a normalized property to make it easier to match values despite of the formatting. So instead of "Creation Date" authors may want to use "Creation Date§".

Sample with normalized date property value.

In case dates or other property types need to be compared, check out Search Functions on Search Tips or read the tip Search Functions.

The Transclude Documents Macro transcludes sections from documents that are part of a result set. The query is also specified by a Where parameter as shown above.

Updating Property Values

Property values may be updated by editing the value in the properties table inside the Document Properties Marker Macro and saving it.

An alternative way of changing values is to use the Web API of the projectdoc Toolbox which is provided by the free Web API Extension. This way a property can be changed by a simple REST call.

Changing values with this REST API can also be made quite simple from within an author's web browser by the use of bookmarklets. Use the free Bookmarklets Extension to get started with defining your own bookmarklets.

Resources

More information on related topics.

Using Space Properties
Space properties are defined for spaces and are accessed via the Space Property Macro. This tip goes into detail in how to use space properties with inheritence and extension pages.
Document Properties
Properties are metadata that can be added to every projectdoc document. If you require a set of metadata for each instance of a document type, you should write your own doctype.
Space Properties
Lists the configuration options at space level.
Tour Macro
Renders a predefined list of documents in a table.
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.
Content Marker Macro
Marks a piece of content within a document. This content can be referenced for transclusion.
Search Tips
Tips on specifying search queries for Lucene. This also applies to projectdoc's query macros.
Search Functions
Using functions to run searches with the projectdoc Toolbox.
Web API Extension
Add-on to extend projectdoc with an API to access on the web.
Bookmarklets Extension
Add-on to extend the Toolkit with Bookmarklets. Allows to execute tools via the browser.