Rules enable you to tell CatBase how to make decisions about publishing and styling your data according to certain criteria that you choose.
To create a new Rule:
Rules are based on the logic:
IF (something is true) THEN (do something) OTHERWISE (do something else) AND ALSO (optionally do something else as well)
There are four areas in the Rule dialog:
The first area in the Rule window is the IF area:
This is where you select your criterion for the Rule.
Start by choosing the selection criterion from the first popup:
Select this option to base your Rule on the contents of a field.
The Selection refers to the group of records being published at that moment. So this could mean various things:
For example ...
In this case, CatBase sorts the Categories (and, if appropriate, sub-categories) according to your specification (most often by Category Name). It then steps through the Categories, finds all the records that go under each Category, sorts those records as you've specified, and publishes them. Suppose, for example, that you're publishing a membership directory and you want the first member in each Category to have their name set in a different stylesheet to the other members in the same Category. You might create a Rule like this:
Note the Style for paragraph option has been selected, and the first in category Stylesheet:
In the Otherwise tab, the Publish the Field: name option has been selected. As each record is published, the Rule is evaluated. If it's the first record in the category, then the first in category Paragraph Stylesheet is applied to the name; otherwise, the default style for the Paragraph is used.
In this case, each group of related records is a Selection. For example, let's suppose you are publishing a catalogue of products that have parts related to them; each Product can have any number of Parts, and those Parts are listed after the product picture. Each Product's list of Parts is a Selection.
In this case the complete group of records being published constitutes the Selection.
This is the same as the "first record in the selection" except that it applies to the LAST record.
A typical use for this option is when you want to have alternating records formatted differently - for example, left-aligned, right-aligned, etc. You can create a Rule to tell CatBase to apply a different Stylesheet if it's an odd-numbered record within the Selection (see above for a discussion of Selections).
Like an odd-numbered record, but applies to the even-numbered ones.
When you choose this option, the display changes:
Suppose you are publishing a directory of Companies and you want to flag whether they have multiple locations or not. The locations are in a related table. If they have only one location (ie, one related Locations record) you want to publish a comment; if they have more than one Location record, you want to publish a different comment. You could create a Rule like this:
IF THE PARAGRAPH IS LONGER THAN ...
When you choose this option, the display changes:
This refers to the length of the current Paragraph at the point where the Rule is encountered - not the overall length of the Paragraph.
For example, maybe you are publishing a personnel directory. On the first line of each entry you want to publish the person's last name, a comma and a space, then their first name, another comma and space, then their business title. But if their complete name is longer than, say, 30 characters, you want their business title to go onto the next line. Your Paragraph would consist of 6 Elements:
Choose this option and the display changes:
A Variable is a value that can change. Specifically, a Script Variable is a value that can be entered into a Publishing Project for use by scripts and Rules.
For example, suppose that you are publishing a membership directory, and you need to create several different versions for different languages. The main content (names, addresses, telephone numbers etc.) will not change, but there is some text that does need to be language-specific. Perhaps the phone number line contains the word "Telephone", and this needs to be translated for each language.
It would be tedious to create a different Publishing Stylesheet for each language. And if you needed to make a change to the content, you would have to remember to make that same change in all the different language versions. Instead, you can set up a Publishing Project and enter the language into the Script Variable field - for example:
Now, in your Rule you can say:
You can create as many Rules as you need - one for each language - then simply change the Script Variable in the Publishing Project as needed.
This option will only appear if your Publishing Stylesheet is based on Categories (ie - the data is sorted first by Category).
You can use this option to control the content or formatting depending upon which category the records are in.
For example, suppose you're publishing a catalogue of electrical components. The products are organised into categories such as "Fuses", "Cables" and so on. You want the product names to be colour-coded according to the category they are in. You could set up a Rule like this:
Note that the Style for paragraph: fuses heading option has been selected. So, when the data is published, if a product is listed under the Fuses category, its name will be set in the style "fuses heading".
The principle is the same as the "category name" option, but the rule is evaluated using the Category Number instead of Name.
When this option is selected, the rule is evaluated based on the "parent" category of the current category - in other words, if you have two Category levels. the top level is the "parent" to the second level.
If you have two or more levels of category, the top level is the first level (Level 1).
When you select Categories for your data, each record can go into any number of Categories. The first one you add will be marked as the Main Category, but you can select a different one to be the Main Category by clicking on the Main Category checkbox in the list of Categories on the record's data entry form.