"Catbase has enabled us to complete projects at a fraction of both the cost and the time of doing so without the Catbase software. In addition the support that the Catbase team have given us has been superb"

– Chalvington Press

Conditional Formatting: How to Publish Data in Different Styles Depending upon Some Criteria

When you are publishing a catalogue, directory, price list, or other database-based publication using QuarkXPress or InDesign, you may have a need to format some data differently depending upon some criteria or other. For example, in a directory perhaps you offer options for listings to be 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 several ways:

Let's look at each method ...

Choice List Fields

A Choice List field is a field that has a specific list of options attached to it. For example, your list might contain choices like:

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 fields can be recognised by the fact that their names are underlined on a data entry form.

To create a Choice List field:

  1. Go to Table and Field Setup (click on the Setup button on the main window and choose Table and Field Setup)
  2. Select the appropriate table
  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
  6. For example:
  7. Save the Field Properties

To modify the options on a Choice List, click on the Setup button on the main CatBase window and choose 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"special offer" option.

Field Content

You can also tell CatBase to consider the contents of a field to decide how to format text or numbers. Here are some examples:

The possibilities are endless!

Step Two: How do you tell CatBase what you want it to do?

That's what Formulas are for!

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

  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. Click on the Formula radio button. The Formula window looks like this:

Formulas 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)

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

Example One: Selecting the Paragraph Style depending on the options in a Choice List.

A typical use for this sort of thing is in a business directory. Everybody is entitled to a free entry, but they can pay extra to have an enhanced entry. Suppose we have a choice list called Listing Level, which offers the following options:

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

  1. Create a Paragraph and select the basicentry stylesheet for that Paragraph
  2. Add an Element and select the Formula radio 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 boldentry stylesheet; OTHERWISE publish the company name using the default styles for the Paragraph (basicentry)"

So our Formula will look like this:

Note the change of style!

The Otherwise tab looks like this:

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.

Example Two: Selecting the Paragraph Style based on a Boolean field

This option works when you have a simple yes/no (or true/false) choice to make - for example, for products that are on special offer (either they are on special offer or they aren't).

In this case we would create a Special Offer field, which would be a Boolean type. It appears on the data entry forms as a check box. If it's checked, the product is on special offer and we want to set the product name in a special style (maybe bigger, bolder, and in red). If it isn't checked, then we want the product name set in the normal productname style. We would set up a Formula like this:

In the Otherwise area, Product Name is selected for Export Field.

Example Three: Selecting formatting based on a field's content

Use this method when you want to base a styling decision on the data that's in a particular field which is not as structured as a choice list field. You can do these comparisons on various types of field, for example:

Let's say we are publishing a catalogue of food products, and we want to highlight everything with "chocolate" in its name by setting it in a bold, brown style using a stylesheet called chocstyle. Our Formula would look like this:

Summary

As you can see, there are lots of ways you can get CatBase to make decisions about the styling of the data based on the content of a record. If you are not quite clear how to solve a particular styling problem, please contact us and we will help you figure it out.

What do do next ...

About Us | Site Map | Privacy Policy | Contact Us | ©2009 CatBase Software Ltd.