top of page

Conditional Formatting

How to publish data in different styles according to criteria that you specify.

When you are publishing a catalogue, directory, price list, or other data-based publication, you may have a need to format some data differently depending upon some criteria or other. This is called conditional formatting. For example, in a directory perhaps you offer free listings in a plain style or for people to pay extra for an enhanced entry - bold, with a logo, with additional information, etc. Or maybe in your catalogue you want to style an item's information differently if it's a new product, or on special offer, for example.

With CatBase it's easy to achieve this! There are just a couple of steps to follow:

  1. What's going to determine the style?

  2. How do you set up CatBase to handle the conditional formatting?

Step One: What determines the style?

How will CatBase decide how to format the data? There are a number of ways:
  • A Choice List

  • A check box (Boolean choice)

  • Content

  • The record's position within the current selection

  • Whether it's an odd- or even-numbered record in the current selection

  • The length of the Paragraph

  • The Catgegory Name or Number

  • Whether it's the Main Category for a record

Let's look at each method ...


Choice Lists

A Choice List field (also known as a Pick List) is a field that has a specific list of options attached to it. For example, a list of styling options might contain choices like:

  • Plain

  • Bold

  • Logo

  • Extended

Instead of entering data directly into a Choice List field, you click on the field and make a selection from a pop-up list - for example:

choice list

To create a Choice List field:

  1. Go to Admin->Database Setup.

  2. Select the table that you want to add the field to.

  3. Either add a new field by clicking on the New Field button, or open an existing field by double-clicking on it. Note that only String type fields can be designated as Choice List fields.

  4. In the Field Properties dialogue box, select the Choice List check box

  5. Either select an existing Choice List or create a new one by clicking on the New List button. If you choose to create a new Choice List, enter a descriptive name for it (this is for your reference - it will show the field name on the data entry form).

For example:

choice list

Save the Field Properties.

To modify the options on a Choice List, go to Admin->Lists.


Check Boxes

A check box is a representation of a Boolean field type: it is True or False (or Yes or No). If the checkbox is checked, it's True; if it isn't, it's False. Check boxes have their uses but keep in mind that they are limited to just two choices - Yes and No! An example of using this option would be a "New product" option - either it's a new product or it isn't.


Field Content

You can also tell CatBase to consider the contents of a field to decide how to format data, and how to make decisions about what to include or omit. Here are some examples:

  • If the Product Name contains "chocolate", set it in a dark brown style instead of the default style.

  • If the price is less than 10.00, set it in the "Bargain Basement" style instead of the default style.

  • If the country is not "USA", set it in a bold red style.

  • If the Enter Date (the date on which the product was added to the database) is greater than (after) 01/01/2016, then set the product name in the "new product" style.

​The possibilities are endless!

Step Two: How do you set up CatBase to handle the conditional formatting?

That's what Rules are for!

Rules are one of the types of Element that are the building blocks of Paragraphs in your Publishing Style Sheets. To create a Rule:

  1. Open your Publishing Style Sheet (or create a new one)

  2. Open a Paragraph (or create a new one)

  3. Add a new Element

  4. Select the Element Type: Rule.

  5. Click the Edit Rule button.


The Rule window looks like this:

Rules enable you to set up rules that follow this pattern:

IF (some condition is met) THEN (do something) OTHERWISE (do something different) AND ALSO (optionally do something else as well).


Rules are described in detail in the Rules Reference. We will look at a couple of examples relevant to conditional formatting of text in this Tutorial.


Example: Conditional Formatting by Selecting the Paragraph Style depending on the options in a Choice List

A typical use for this sort of thing is in a telephone directory. Every company is entitled to a free listing, but they can pay extra to have an enhanced entry. Suppose we have a choice list called Entry Style, which offers the following options:

  • Basic

  • Bold

  • Superbold


A Basic listing is the free option; their basic contact details are published, set in a plain font using a stylesheet called plain listing.

A Bold listing is a paid upgrade; they get their basic contact details set in bold using a stylesheet called listing bold.

Superbold listing is another paid enhancement; they get their contact details set in bold, using the listing bold stylesheet, plus a brief description of the product or service they offer.

The first line of detail for each listing contains the company name, set in the appropriate style (plain listing or listing bold). So, to publish the Company Name, appropriately styled:

  1. Create a Paragraph and select the plain listing stylesheet for that Paragraph

  2. Add an Element and select the Rule Element Type.

  3. Click the Edit Rule button.


The decision that we want CatBase to make is this:

"IF the Listing Level is not Basic, THEN publish the company name using the listing bold stylesheet; OTHERWISE publish the company name using the default style for the Paragraph (plain listing)"

So our Rule will look like this:

rule for conditional formatting

Note the change of style!

rule to change stylesheet

Note also that the Publish Text radio button is selected, but nothing is entered into the text area. Effectively this means "publish nothing".

The Otherwise tab looks like this:

In other words:

OTHERWISE do nothing

This is a simple example that shows how to choose between two styles; you can set up more complex decisions by creating multiple Paragraphs with different stylesheets selected, and then using the Include this Paragraph option.

Learn more about Rules on the Rules Reference page.
bottom of page