Conditions and conditional content
Use of conditional content is a powerful technique supporting content reuse. It enables the same objects to be reused across various publications and contexts rather than constricting these objects to a specific publication and context. Apply conditions to context-specific content and then show that content only when the conditions are met, as set in the publication's context.
What are conditions?
In the context of content management, the term conditional content means content that is included in the output only when specific criteria, the conditions, are met. A condition is a rule that defines the selection criteria for determining what content to show. The basic rule construction is a condition name paired with a condition value.
For example, you might use an "audience" condition to qualify content as being intended only for a certain type of user or a "format" condition to designate content that is only relevant to a certain output format. The corresponding name-value pairs might be audience=beginner and format=online.
DITA versus Tridion Docs
In DITA generally, you make content conditional through use of DITA profiling attributes, such as @product, @platform and @audience, and possibly a ditaval file to specify which attributes to show or not to show. You can set conditions on individual XML elements by defining a value for the element's Condition attribute.
Defining condition names and values
Adding conditions to content
You can set conditions on individual XML elements by defining a value for the element's Condition attribute. Within a single @ishcondition attribute, the value can be a simple name-value pair or a complex expression.
- Individual elements within a topic, the lowest level
- Entire topics within a map
- Entire maps within a parent map, the highest level
Setting the publication context
For each publication where conditions are used, you should define the publication context, that is, a set of rules that you construct by selecting conditions and values. The context determines which conditional content should be shown in this publication versus which content should be hidden.
You can define the context in Publication Manager application.
Based on the context, Tridion Docs applies conditional processing to transform the content whenever a user previews topics or maps in Publication Manager, views the publication in Collective Spaces or publishes the content to any of the defined outputs.
Viewing conditional content
The following list describes the how conditional content appears when you are using one of the authoring tools:
- Publication Manager
-
When you select a topic from the Content tab and view it in the preview panel, all conditional text that exists in the topic appears (nothing is hidden), but highlighting indicates whether it will be shown or hidden in the published output.
The preview uses the following highlighting for conditional text:- Green background: the text is included when you publish the publication.
- Red background: the text is excluded when you publish the publication.
- XML authoring tool
-
The different authoring applications support the DITA conditional content in different ways. Refer to the documentation for the product you are using.
- Draft Space
-
In Draft Space, conditions are presented in the Outline and in the Document view. Objects in the Outline that are conditioned out of the publication are rendered with a strike-through line crossing the title of excluded object.
Objects that are conditioned out of the publication are also rendered with a red x-mark and "Excluded" label in the Document view.
- Review Space
- In Review Space, objects that are conditioned out of the publication are not rendered in Review Space Outline and Document view.
Filtering during publishing
Before a publication is rendered into the desired output, content that does not match the context is filtered out. This enables you to generate different outputs from the same publication by specifying different contexts when you publish.