Yadabyte
 
Authoring TR files
 
Basic TR File Structure
 
How to make a TR File
 
Categories
 
Other Category Options

Categories

Categories are a new edition to TR3 and we think they are by far the most powerful and impressive of the new features.

To use categories in TR3 files there are two stages, Defining the category for the file and setting the category for the individual entry (page, section.)

 

Defining Basic Categories

Lets define a category that we will use in a nutrition reference work. The category will define for the type of food, say, Fruit, Meat, Fish etc.

Categories are defined at the start of the file, before any <new> tags have been used. They are defined as follows:

<catdef>

name = Food_Type

</catdef>

This tells TomeRaider that there is a text based category called Food_Type and it should look out for this in the pages that follow.

 

Setting Basic Categories

So, we have the Food_Type category defined now we need to use it by setting which foods in our TomeRaider file belong to which categories. This is done using the <catset> tag as follows:

<new>Apple

<catset>Food_Type= "Fruit"</catset>

The <catset> tag can appear anywhere within the page for the item and of course there can be many category settings in one page, perhaps like:

<new>Lemon

<catset>Food_Type= "Fruit" </catset>

<catset>Colour= "Yellow" </catset>

<catset>Taste= "Bitter" </catset>

So, we have seen how to define categories and how easy it is to do. But the categories we have defined are pretty simple. TomeRaider 3 allows much more complex categories to be defined and used. Allowing us to have multiple categories set for one defined category and numerical categories that can be used for numerical filtering and querying.

 

Defining Numeric Categories

To define a category that will hold a number that can be used in numerical filters is done by using the keywords "type = numeric" within the category definition .

Just like this:

<catdef>

name = Calories

type = numeric

</catdef>

 

Setting Numeric Categories

Numeric categories are set in the same way as Basic Categories but instead of strings we use a number, like this:

<new>Lemon

<catset>Food_Type= "Fruit" </catset>

<catset>Calories= 43 </catset>

 

Defining Multiple Categories

We saw with basic categories that you can set one string of text to a category. However sometimes you might want to have one category holding many values, in our nutrition database we might want to have a category for Vitamins that can hold any number of vitamins for a given food. To do this we use the keywords "multiple= Yes" like this

<catdef>

name = Vitamins

multiple = yes

</catdef>

 

Setting Multiple Categories

<new>Salmon

<catset>Food_Type= "Fish" </catset>

<catset>Calories= 145 </catset>

<catset>Vitamins= "Vitamin A" </catset>

<catset>Vitamins= "Vitamin C" </catset>

<catset>Vitamins= "Vitamin B12" </catset>

<catset>Vitamins= "Vitamin B6" </catset>

Note that Multiple categories can also be set using a comma separated list, as in:

<new>Salmon

<catset> Vitamins= "Vitamin A", "Vitamin C" , "Vitamin B12" </catset>
 | Site Map | Copyright © 2005 Yadabyte. All Rights Reserved. This is a Yadasite.
Yadabyte