summaryrefslogtreecommitdiff
path: root/TWiki/TWikiCategoryTable.mdwn
blob: 96abcca112f44a0700de556cb4d5827849b3e037 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
**_What is a Category Table?_**

A Category Table is a table that can include drop-down menus, checkboxes, radio buttons, and text fields. It makes it easy to provide keywords to categorize a topic.

For example, if a TWiki web is devoted to technical support, wiki topics might be incident reports. The Category Table can prompt the writer to select the operating system, the software product, and the version for this report. For the operating system category, checkboxes can be displayed for OsSolaris, OsSunOS, OsHPUX and OsWin.

**_Using a Category Table_**

It is possible to add a category table to a TWiki web. This permits storing and searching for more structured information. Editing a topic shows a HTML form with the usual text area and a table with selectors, checkboxes, radio buttons and text fields. The category table is shown at the end of a topic. The format of the category table can be defined per TWiki web.

If you want to add a Category Table in a TWiki web you need to place the following three files into the `twiki/templates/{Yourweb}` directory:

* `twikicatitems.tmpl` : Defines the items in the table
* `twikicatedit.tmpl` : Defines the look of the table when editing a topic
* `twikicatview.tmpl` : Defines the look of the table when viewing a topic

**_Format of category definition template twikicatitems.tmpl_**

Valid lines:

    select|{name}|{selSize}|{val1}|{val2}|{val3}...
    checkbox|{name}|{checkFlag}|{itemsPerLine}|{val1}|{val2}|{val3}...
    radio|{name}|{itemsPerLine}|{val1}|{val2}|{val3}...
    text|{name}|{charSize}
    # comments start with a # character

Explanation:

      {name}             name of tag
      {selSize}          vertical size of SELECT tag
      {val1}|{val2}...   values
      {checkFlag}        set to true for [Set] [Clear] buttons, else set to false
      {itemsPerLine}     input items per line before wrap around, 0 if no wrap around
      {charSize}         number of characters for text fields

**_Remark:_** Line `radio|UseCategory|0|Yes|No` has a special meaning. If present, it is possible to choose in "edit" if the category table is included in the topic or not

Example file:

    radio|UseCategory|0|Yes|No, delete this category table
    select|TopicClassification|1|Select one...|NoDisclosure|PublicSupported|PublicFAQ
    checkbox|OperatingSystem|true|5|OsSolaris|OsSunOS|OsHPUX|OsWin
    text|OsVersion|16

**_Format of twikicatedit.tmpl and twikicatview.tmpl_**

Use the example below and customize if needed. `twikicatedit.tmpl` and `twikicatview.tmpl` can be identical, but they do not have to be.

**_Attention:_** `<!--TWikiCat-->` is needed at the beginning and end as markers. Do not delete them!

Example:

    <!--TWikiCat--> <h4> TWikiCategory </h4>
    <table border="2" cellspacing="1" cellpadding="1">
    %REPEAT%<tr>
    <td valign="top" align="right"> %CATNAME%:  <br>%CATMODIFIER%</td><td>  %CATVALUE% </td>
    </tr>%REPEAT%
    </table><!--TWikiCat-->

Above template files will result in the following category table when **_viewing_** a topic:

#### <a name="TWikiCategory_a_"> </a> [TWikiCategory]()

<table border="2" cellpadding="1" cellspacing="1">
  <tr>
    <td align="right" valign="top"><a href="">TopicClassification</a>: <br />
    </td>
    <td><a href="">PublicFAQ</a></td>
  </tr>
  <tr>
    <td align="right" valign="top"><a href="">OperatingSystem</a>: <br />
    </td>
    <td><a href="">OsSolaris</a></td>
  </tr>
  <tr>
    <td align="right" valign="top"><a href="">OsVersion</a>: <br />
    </td>
    <td>2.5  </td>
  </tr>
</table>

Above template files will result in the following table when **_editing_** a topic:

<form><nop><h4><a name="TWikiCategory_a_"> </a> <a href="">TWikiCategory</a></h4>
    <table border="2" cellpadding="1" cellspacing="1">
      <tr>
        <td align="right" valign="top"><a href="">UseCategory</a> : <br />
        </td>
        <td>
          <table cellpadding="0" cellspacing="0">
            <tr>
              <td><input checked name="UseCategory" type="radio" value="Yes" />Yes   </td>
              <td><input name="UseCategory" type="radio" value="Nodeletethiscategorytable" />No, delete this category table   </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td align="right" valign="top"><a href="">TopicClassification</a> : <br />
        </td>
        <td><select name="TopicClassification" size="1"><option value="Selectone">Select one... </option>
            <option value="NoDisclosure">NoDisclosure </option>
            <option value="PublicSupported">PublicSupported </option>
            <option selected value="PublicFAQ">PublicFAQ </option></select></td>
      </tr>
      <tr>
        <td align="right" valign="top"><a href="">OperatingSystem</a> : <br /><input onclick="" type="button" value=" Set " />  <input onclick="" type="button" value="Clear" /> </td>
        <td>
          <table cellpadding="0" cellspacing="0">
            <tr>
              <td><input checked name="OperatingSystemOsSolaris" type="checkbox" />OsSolaris   </td>
              <td><input name="OperatingSystemOsSunOS" type="checkbox" />OsSunOS   </td>
              <td><input name="OperatingSystemOsHPUX" type="checkbox" />OsHPUX   </td>
              <td><input name="OperatingSystemOsWin" type="checkbox" />OsWin   </td>
            </tr>
          </table>
        </td>
      </tr>
      <tr>
        <td align="right" valign="top"><a href="">OsVersion</a> : <br />
        </td>
        <td><input name="OsVersion" size="16" type="text" value="2.5" /></td>
      </tr>
    </table></nop></form>

**_Note:_** It is possible to force the values of a category table when creating a new topic. This is useful to create new topics using a form for the topic name. The default values of the category table can be specified as hidden fields if needed, i.e. `<input type="hidden" name="someCategory" value="someValue">`

Example (edit this page to see the source) :

* <form action="%SCRIPTURLPATH%/edit%SCRIPTSUFFIX%/Know/"> New <span style="background:"><font color="">Public FAQ</font></span><a href="http://LOCATIONKnow/PublicFAQ">?</a> topic: <input name="topic" size="32" type="text" /> <input name="TopicClassification" type="hidden" value="PublicFAQ" /> <input name="OperatingSystem" type="hidden" value="OsSolaris,OsSunOS" /> <input name="OsVersion" type="hidden" value="Just testing..." /> <input name="onlywikiname" type="hidden" value="on" /> <input type="submit" value="Create Topic" /></form>

-- [[Main/PeterThoeny]] - 21 Apr 2000 <br />