projectdoc Toolbox

Define a doctype on document instances to select from its set of values.

Parent
Audience
Level of Experience
Expected Duration
30 min
Type
Contents

Authors often need to select a property value from a set of values. There are selection macros that provide this functionality. But writing a new macro requires programming skills and demands additional effort in maintaining and deploying the add-on with the macro. The projectdoc Toolbox allows authors to define ad-hoc doctypes and to select from these values using the Name List Macro.

 

Ad-hoc Doctype

A doctype typically defines a template with a set of properties and sections. It comes with a wizard to support authors to create new instances of this doctype. The name of the doctype is part of each document instance. It is defined by the document property named Doctype.

An ad-hoc doctype is a doctype that has no template and no sections. It is a page that employs the Document Properties Marker Macro to define the document properties and the Section Macro to define the sections. And it sets the value of the Doctype property to a selected value. So an ad-hoc Doctype is a doctype that is defined by document instances simply by setting the Doctype property to a value.

Authors may create the document instances from scratch by creating a blank document and add the properties and sections. The ad-hoc doctype can also be derived from an existing doctype that comes closest to the author's requirements. If no existing doctype comes close, the Generic Doctype is typically useful. It provides the basic properties that are commonly shared by all doctypes (such as Name, Short Description, or Tags).

Define Ad-hoc Doctype

For this short example we assume that the author needs to define a set of file formats to select from. For this example we assume that authors should select from these file formats:

  • CSV (Comma Separated Values)
  • JSON (JavaScript Object Notation)
  • XML (Extensible Markup Language)

The new doctype is identified by file-format.

Create Doctype Homepage

To store the file format documents the author may choose to create a new homepage. The documents may be stored at any location, but for this example we create a new page called "File Formats".

The easiest approach would be to copy an existing doctype homepage and adjust it according to the author's requirements. But for this tip we do not go the easiest way and create the new page as a child to the space hompage manually. We create a blank page and add the Document Properties Marker Macro with the following values.

In order to automatically select documents that are associated with a file format, we add the Display Table Macro within a Section Macro like this:

For the Display Table Macro set the following parameters:

Parameter NameParameter Value
Doctype(s)file-format
Restrict to immediate Childrentrue

Save the page!

Create File Formats

Now create three document instances for CSV, JSON, and XML.

We assume that the homepage for File Formats is the current page.

Create a new page of type Generic.

Add name and short description.

Edit the properties Doctype, Iteration (optional), and add the CSS Style Information (optional, but recommended).

The Doctype is set to the new ad-hoc doctype named file format. This is the important part. The Iteration is set to Filled to indicate that this document is about to be ready for action (any value will do, but a non-Facade value indicates that we started to work with it). The CSS Style Information will later instruct projectdoc to render a blue box instead of a text value. If you prefer a simple text value, skip this.

Remove the label "generic" from the page. You may want to add the label "file-format".

We want to automatically collect all documents with the format set to CSV. To do this we add a section to the document with the Display Table Macro like this:

Set the Where parameter to $<Format>=[${Name}].

This will select documents of any type that provide a document property called Format and specify a value that matches that of this documents.

 

You could hard-code "Format=CSV" or "$<Format>=[CSV]" for exact matches to yield the same result. But since we want to copy this page to create the document instanced for JSON and XML this makes it a lot easier! (smile)

Please refer to Search Tips for more information on searches with the projectdoc Toolbox.

Save the page!

Copy the page to create document instances for JSON and XML. Alter the title of the page and the properties Name, Short Description and CSS Style Information accordingly.

Now change to the doctype homepage to see the three document instances.

Make them Boxes!

If the values should be rendered as boxes a space property has to be set. Currently we defined the styles, but the projectdoc Toolbox needs to instructed to actually take this configuration into account.

Go to the space homepage (or one of its delegate spaces) and set the property name-list-file-format-box-style to true.

Use File Format

Every new document may now use the file formats by the document property "Format". The property name is "Format" since this is the property we select on previously using the Display Table Macro.

Create a new document of any type. In this example we create a Topic document.

Add the Format property with the Name List Macro as value.

Open the Name List Macro and set the Doctype and restrict the values to range.

To select a value temporarily deselect "Empty Where Clause Handling".

Then and click "Preview":

Select the appropriate value by clicking on the copy icon (). It is recommended to select the "Empty Where Clause Handling". The click "Preview":

Save the macro then save the page.

Click on the CSV box:

The documents referencing the CSV file format are automatically listed!

Limitations

This approach has some limitations.

Clumsy Selection

The author needs to use a workaround employing the Empty Where Clause Handling parameter to get a list of valid values in the browser. She then needs to type (or copy-paste) the value.

PDAC-632 - Getting issue details... STATUS

Definition of Doctype is work

The definition of the documents for each value and the homepage for these values is a lot of work at first. But additional values are added quite simply.

The advantage is that these pages provide an additional navigation structure that makes it easy to find documents related to a value.

Resources

Name Short Description
Doctypes and the Name List Macro allow to specify a range of valid tokens for a value. These values can be rendered by applying specific CSS styles.
What if no existing doctype matches the purpose of the document? Here are some tips how to handle this situation.
Controls, the default whether or not the Name List Macro renders a small box around each entry for a specific doctype. The default behavior is false and can be set to true by using the space property name-list-default-boxstyle.
Lists the configuration options at space level.