You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

projectdoc Toolbox

Show how to use the Name List Macro to render links to glossary terms.

Contents

The Name List Macro of the projectdoc Toolbox for Confluence allows users to wrap a label with a macro that eventually renders a link to a document with the given name.

This short tip shows how this macro can be used to render links to glossary items.

What is in the Name List?

First we want to provide some theory about the differences between a Confluence Link, the Name List Macros (there a two of them) and the Display Properties Macros (there are a bunch of them).

If you want to reference a piece of information found in a page or projectdoc Document, you basically have the three options listed above.

In case you do not care for some theory, skip the following section a go straight to Name Links in Sections.

Display Property Macros

The Display Property Macros are very similar to the Confluence Link. They are also hard-wired and point to a Confluence page. Instead of showing the page title, the macro allows to select any property (or multiple properties in form of a template) to be rendered. The user may select whether or not a link should be rendered. In case you show the name or the short name of the document, you typically want to render the link. In case you list the type property, the value is already a link to a type document and therefore no additional link is typically useful.

Display Property Macros do provide a separate label. You may either render the property value, or you don't. If you would like to change the label you should consider to use a Confluence Link.

Here is the list of macros that belong to this family:

Display Document Property Macro
Renders the value of a property of a document.
Display Document Properties Macro
Renders a template with property references.
Display Document Property Ref Macro
Displays a document property from a referenced document.
Display Document Property Ref Concat Macro
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.

Note that the Tour Macro and the Tour-by-Property Macro also belongs to this family. They provide static references, but list the properties of a set of documents. The Display Table Macro and the Display List MacroDisplay List Template Macro also belong to this family, but are slightly different. Instead of pointing to one document statically, they point to a set of properties that match the query constraints (and are therefore also related to the Name List Macros we examine in the next section).

Display Property or Display Document Property?

 

When the context is clear referring to documents, we call the Display Document Property Macros simply Display Property Macros. There is also the Display Space Property Macro to display space properties. If we talk about both types of macros, we need to use the precise name.

Name List Macros

Name List Macros are a complete different beast. The Name List Macro is often used as a property value. This is on first sight quite natural. The Name List Macro is a label wrapped inside a macro. The macro decides whether or not a link is rendered. The link is based on a query. It is not static as in case of the Confluence Link or the Display Property Macros.

Besides the name specified, the query is based on the delegate space and the doctype parameter. Per convention the tuple of name and doctype should be unique within the delegate space closure. This is not enforced. If there are multiple name/doctypes that match, the first match will be used for the link.

Therefore the contract of the Name List Macros is this: I know for sure what the text label is I want to place here. But I am unsure if there is a document on the delegate space closure that matches name and doctype. Therefore the basic behavior of the Name List Macro to a change of the name of the referenced document is not to also change the its label text. This is like a variable in a computer program. If you change the name of one variable, the names of the same variable in other lines are not automatically updated. If you want this, you need to call a refactoring operation "Rename local variable". Page authors often expect that changing the name of a document will change the label text of every Name List Macro that happen to have the old name. But this is not the case.

One beauty of this macro is its use for template authors: Template authors cannot reference document instances when designing space or page templates. But they can specify the name of a to-be-created document that is part of your design domain. And also if a space is exported. Often the type documents referenced in Name Macros are separately managed in an index space. In case the site the exported space will be imported to also has these documents, they do not need to be exported, too. In case a single document is not available on the new site then no information is lost. The property value has still the name and a link will be rendered once the missing document is created.

Currently there is also a known drawback if the Name List Macro is used as a property value. Since property values are cached for fast access, the link will not be rendered for a Name List Macro once the referenced document comes into existence. This is an issue of the projectdoc Toolbox we plan to address in one of the releases to come. Meanwhile you need to either refresh the cache using Cache Refresh Actions or to make a change to the document and publish it. This is only an issue when used as a property value. If the macro is used inside a section, the value will be updated on request time.

Note that the Name List Macros are the only dynamic macros allowed as document property values. This is because the value of the macro is static. Only the link information is dynamic. Having or not having a link makes no difference in the Lucene search. Therefore everything is cool using a Name List Macro as a property value.

There are two variants of this macro:

Name List Macro
Lists references to projectdoc documents. The rendering will add a link to a document, if there is a document with the given name.
Name Body List Macro
Lists references to projectdoc documents. The rendering will add a link to a document, if there is a document with the given name hat is added to the body.
Tag List Macro
Renders a name list while taking care of special tag semantics. Confluence labels are added virtually to this list and displayed in the tags table row of the document properties table.
Role List Macro
Renders a name list while taking care of special role semantics. Confluence names of groups with view permissions are added to the list of values.

Summary in Brief

So these are the characteristics of your link options:

Confluence Link
  • static link
  • allows to control the label
  • does only update label if label is not changed
Display Property Macros
  • static link
  • does not allow to control the label
  • updates on change of property value
Name List Macros
  • dynamic link
  • owns the label (allows to change it)
  • is always pointing to the current document (unless used as a property value)

So much for some theory on working with links in Confluence and the projectdoc Toolbox.

Name Links in Sections

The Name List Macro can be used in sections. Suppose you link to a term Confluence Page in your glossary.

Link with Tooltip

Now let's create the entry in the glossary:

Reloading the page with the link will now render a link. At the time of this request, the document for the glossary item exists.

The advantage of the Name List Macro over a Confluence Link is the rendering of the referenced document's short description as tooltip when hovering over the link.

Control the Label's Text

With version 2.3 of the projectdoc Toolbox the Name List Macro also provides a Label Parameter. In case the Name List shows only one name, the label is replacing the name. What is this good for?

Imagine that you need to change the label from Confluence Page to confluence pages:

The result is this:

The new Name List Macro makes it possible to add links to words that fit to the English sentence.

Drawbacks

Adding Confluence Links is easy since there is an auto-complete for matching page titles. When page authors use the Name List Macro, they need to know exactly the name of the document and the name of the doctype they want to refer to.

With the release of the projectdoc Toolbox version 3.3 there will be support for auto-complete for the Name List Macro and Display Document Property Macros. This release is planned to happen in autumn 2019.

  • No labels