1 <a name="TWikiMetaData"></a>
3 # <a name="TWiki Meta Data"></a> TWiki Meta Data
5 _Additional topic data, program-generated or from [[TWikiForms]], is stored embedded in the topic text using `META:` tags_
9 <li><a href="#TWiki Meta Data"> TWiki Meta Data</a><ul>
10 <li><a href="#Overview"> Overview</a></li>
11 <li><a href="#Meta Data Syntax"> Meta Data Syntax</a></li>
12 <li><a href="#Meta Data Specifications"> Meta Data Specifications</a><ul>
13 <li><a href="#META:TOPICINFO"> META:TOPICINFO</a></li>
14 <li><a href="#META:TOPICMOVED"> META:TOPICMOVED</a></li>
15 <li><a href="#META:TOPICPARENT"> META:TOPICPARENT</a></li>
16 <li><a href="#META:FILEATTACHMENT"> META:FILEATTACHMENT</a></li>
17 <li><a href="#META:FORM"> META:FORM</a></li>
18 <li><a href="#META:FIELD"> META:FIELD</a></li>
19 <li><a href="#Recommended Sequence"> Recommended Sequence</a></li>
22 <li><a href="#Viewing Meta Data in Page Source"> Viewing Meta Data in Page Source</a></li>
23 <li><a href="#Rendering Meta Data"> Rendering Meta Data</a></li>
29 ## <a name="Overview"></a> Overview
31 By default, TWiki stores topics in files on disk, in a really simple and obvious directory structure. The big advantage of this approach is that it makes it really easy to manipulate topics from outside TWiki, and is also very safe; there are no complex binary indexes to maintain, and moving a topic from one TWiki to another is as simple as copying a couple of text files.
33 To keep eveything together in one place, TWiki uses a simple method for embedding additional data (program-generated or from [[TWikiForms]]) in topics. It does this using `META:` tags.
35 `META:` data includes program-generated info like [[FileAttachment]] and topic movement data, and user-defined [[TWikiForms]] info.
37 ## <a name="Meta Data Syntax"></a> Meta Data Syntax
39 - Format is the same as in [[TWikiVariables]], except all fields have a key.
40 - `%META:<type>{key1="value1" key2="value2" ...}%`
42 - Order of fields within the meta variables is not defined, except that if there is a field with key `name`, this appears first for easier searching (note the order of the variables themselves is defined).
44 - Each meta variable is on one line.
46 - Values in meta-data are URL encoded so that characters such as \\n can be stored.
48 > **Example of Format**
50 > %META:TOPICINFO{version="1.6" date="976762663" author="LastEditorWikiName" format="1.0"}%
52 > %META:TOPICMOVED{from="Codev.OldName" to="Codev.NewName"
53 > by="TopicMoverWikiName" date="976762680"}%
54 > %META:TOPICPARENT{name="NavigationByTopicContext"}%
55 > %META:FILEATTACHMENT{name="Sample.txt" version="1.3" ... }%
56 > %META:FILEATTACHMENT{name="Smile.gif" version="1.1" ... }%
57 > %META:FORM{name="WebFormTemplate"}%
58 > %META:FIELD{name="OperatingSystem" value="OsWin"}%
59 > %META:FIELD{name="TopicClassification" value="PublicFAQ"}%
61 ## <a name="Meta Data Specifications"></a> Meta Data Specifications
63 The current version of Meta Data is 1.0, with support for the following variables.
65 ### <a name="META:TOPICINFO"></a> META:TOPICINFO
67 <table border="1" cellpadding="0" cellspacing="0">
69 <th align="center" bgcolor="#99CCCC"><strong> Key </strong></th>
70 <th align="center" bgcolor="#99CCCC"><strong> Comment </strong></th>
74 <td> Same as RCS version </td>
78 <td> integer, unix time, seconds since start 1970 </td>
82 <td> last to change topic, is the REMOTE_USER </td>
86 <td> Format of this topic, will be used for automatic format conversion </td>
90 ### <a name="META:TOPICMOVED"></a> META:TOPICMOVED
92 This is optional, exists if topic has ever been moved. If a topic is moved more than once, only the most recent META:TOPICMOVED meta variable exists in the topic, older ones are to be found in the rcs history.
94 `%META:TOPICMOVED{from="Codev.OldName" to="Codev.NewName" by="talintj" date="976762680"}%`
96 <table border="1" cellpadding="0" cellspacing="0">
98 <th align="center" bgcolor="#99CCCC"><strong> Key </strong></th>
99 <th align="center" bgcolor="#99CCCC"><strong> Comment </strong></th>
103 <td> Full name, i.e., web.topic </td>
107 <td> Full name, i.e., web.topic </td>
111 <td> Who did it, is the REMOTE_USER, not WikiName </td>
115 <td> integer, unix time, seconds since start 1970 </td>
121 - at present version number is not supported directly, it can be inferred from the RCS history.
122 - there is only one META:TOPICMOVED in a topic, older move information can be found in the RCS history.
124 ### <a name="META:TOPICPARENT"></a> META:TOPICPARENT
126 <table border="1" cellpadding="0" cellspacing="0">
128 <th bgcolor="#99CCCC"><strong> Key </strong></th>
129 <th bgcolor="#99CCCC"><strong> Comment </strong></th>
133 <td> The topic from which this was created, typically when clicking on a <code>?</code> questionmark link, or by filling out a form. Normally just <code>TopicName</code>, but it can be a full <code>Web.TopicName</code> format if the parent is in a different Web. </td>
137 ### <a name="META:FILEATTACHMENT"></a> META:FILEATTACHMENT
139 <table border="1" cellpadding="0" cellspacing="0">
141 <th bgcolor="#99CCCC"><strong> Key </strong></th>
142 <th bgcolor="#99CCCC"><strong> Comment </strong></th>
146 <td> Name of file, no path. Must be unique within topic </td>
150 <td> Same as RCS revision </td>
154 <td> Full path file was loaded from </td>
162 <td> integer, unix time, seconds since start 1970 </td>
166 <td> the REMOTE_USER, not WikiName </td>
170 <td> As supplied when file uploaded </td>
174 <td><code>h</code> if hidden, optional </td>
178 Extra fields that are added if an attachment is moved:
180 <table border="1" cellpadding="0" cellspacing="0">
182 <th bgcolor="#99CCCC"><strong> Key </strong></th>
183 <th bgcolor="#99CCCC"><strong> Comment </strong></th>
187 <td> full topic name - web.topic </td>
191 <td> the REMOTE_USER, not WikiName </td>
195 <td> full topic name - web.topic </td>
199 <td> integer, unix time, seconds since start 1970 </td>
203 ### <a name="META:FORM"></a> META:FORM
205 <table border="1" cellpadding="0" cellspacing="0">
207 <th bgcolor="#99CCCC"><strong> Key </strong></th>
208 <th bgcolor="#99CCCC"><strong> Comment </strong></th>
212 <td> A topic name - the topic represents one of the [[Main/TWikiForms]]. Can optionally include the web name (i.e., web.topic), but doesn't normally </td>
216 ### <a name="META:FIELD"></a> META:FIELD
218 Should only be present if there is a META:FORM entry. Note that this data is used when viewing a topic, the form template definition is not read.
220 <table border="1" cellpadding="0" cellspacing="0">
222 <th bgcolor="#99CCCC"><strong> Key </strong></th>
223 <th bgcolor="#99CCCC"><strong> Name </strong></th>
227 <td> Ties to entry in [[Main/TWikiForms]] template, is title with all bar alphanumerics and . removed </td>
231 <td> Full text from [[Main/TWikiForms]] template </td>
235 <td> Value user has supplied via form </td>
239 ### <a name="Recommended Sequence"></a> Recommended Sequence
241 There is no absolute need for Meta Data variables to be listed in a specific order within a topic, but it makes sense to do so a couple of good reasons:
243 - form fields remain in the order they are defined
244 - the `diff` function output appears in a logical order
246 The recommended sequence is:
249 - `META:TOPICPARENT` (optional)
251 - `META:TOPICMOVED` (optional)
252 - `META:FILEATTACHMENT` (0 or more entries)
253 - `META:FORM` (optional)
254 - `META:FIELD` (0 or more entries; FORM required)
256 ## <a name="Viewing Meta Data in Page Source"></a> Viewing Meta Data in Page Source
258 When viewing a topic the <code>**Raw Text**</code> link can be clicked to show the text of a topic (i.e., as seen when editing). This is done by adding `raw=on` to URL. `raw=debug` shows the meta data as well as the topic data, ex: [[debug view for this topic|%WEB%/%TOPIC%?raw=debug]]
260 <a name="MetaDataRendering"></a>
262 ## <a name="Rendering Meta Data"></a> Rendering Meta Data
264 Meta Data is rendered with the %META% variable. This is mostly used in the `view`, `preview` and `edit` scripts.
266 You can render form fields in topic text by using the FORMFIELD variable. Example:%BR% `%FORMFIELD{"TopicClassification"}%` %BR% For details, see [[VarFORMFIELD]].
268 Current support covers:
270 <table border="1" cellpadding="0" cellspacing="0">
272 <th bgcolor="#99CCCC"><strong> Variable usage: </strong></th>
273 <th bgcolor="#99CCCC"><strong> Comment: </strong></th>
276 <td><code>%META{"form"}%</code></td>
277 <td> Show form data, see [[Main/TWikiForms]]. </td>
280 <td><code>%META{"formfield"}%</code></td>
281 <td> Show form field value. Parameter: <code><b>name="field_name"</b></code>. Example:%BR% <code>%META{ "formfield" name="TopicClassification" }%</code></td>
284 <td><code>%META{"attachments"}%</code></td>
285 <td> Show attachments, except for hidden ones. Options: <br /><code><b>all="on"</b></code>: Show all attachments, including hidden ones. </td>
288 <td><code>%META{"moved"}%</code></td>
289 <td> Details of any topic moves. </td>
292 <td><code>%META{"parent"}%</code></td>
293 <td> Show topic parent. Options: <br /><code><b>dontrecurse="on"</b></code>: By default recurses up tree, at some cost. <br /><code><b>nowebhome="on"</b></code>: Suppress WebHome. <br /><code><b>prefix="..."</b></code>: Prefix for parents, only if there are parents, default <code>""</code>. <br /><code><b>suffix="..."</b></code>: Suffix, only appears if there are parents, default <code>""</code>. <br /><code><b>separator="..."</b></code>: Separator between parents, default is <code>" > "</code>. </td>
297 **_Note:_** SEARCH can also be used to render meta data, see examples in [[FormattedSearch]] and [[SearchPatternCookbook]].
299 **_Related Topics:_** [[DeveloperDocumentationCategory]], [[UserDocumentationCategory]]