none
[openafs-wiki.git] / TWiki / TWikiTemplates.mdwn
index f5f9a53..52a2042 100644 (file)
@@ -3,9 +3,9 @@
     <li><a href="#TWiki Templates"> TWiki Templates</a><ul>
         <li><a href="#Overview"> Overview</a></li>
         <li><a href="#Major changes from the previous"> Major changes from the previous template system</a></li>
-        <li><a href="#Functional Specifications"> Functional Specifications</a></li>
-        <li><a href="#TWiki Master Template"> TWiki Master Template</a></li>
+        <li><a href="#How Template Variables Work"> How Template Variables Work</a></li>
         <li><a href="#Types of Template"> Types of Template</a><ul>
+            <li><a href="#Master Templates"> Master Templates</a></li>
             <li><a href="#HTML Page Templates"> HTML Page Templates</a></li>
             <li><a href="#Template Topics"> Template Topics</a><ul>
                 <li><a href="#Template Topics in Action"> Template Topics in Action</a></li>
@@ -31,7 +31,7 @@ _Definition of the templates used to render all HTML pages displayed in TWiki_
 
 ## <a name="Overview"></a> Overview
 
-The new modular template system offers flexible, easy control over the layout of all TWiki pages. The master template approach groups parts that are shared by several templates - like headers and footers - in a common file. Special variables allow individual layouts to include parts from a master template - variables are mixed with regular HTML mark-up for template-specific content.
+The new modular template system offers flexible, easy control over the layout of all TWiki pages. The master template approach groups parts that are shared by several templates - like headers and footers - in a common file. Special variables allow individual layouts to include parts from a master template - variables are mixed with regular HTML markup for template-specific content. Templates are used to define [[page layout|Main/WebHome#HtmlTemplates]], and also to supply [[default content|Main/WebHome#TemplateTopics]] for new pages.
 
 ## <a name="Major changes from the previous"></a><a name="Major changes from the previous "></a> Major changes from the previous template system
 
@@ -41,25 +41,35 @@ Where the old templates were each complete HTML documents, the new templates are
 - defines common variables, like a standard separator (ex: "|"), in the base template;
 - defines variable text in the individual templates and passes it back to the base template.
 
-## <a name="Functional Specifications"></a> Functional Specifications
+<a name="TemplateVariables"></a>
+
+## <a name="How Template Variables Work"></a> How Template Variables Work
 
 - Special template directives (or preprocessor commands) are embedded in normal templates.
-- Use of template directives is optional, templates work without them.
 - All template preprocessing is done in `&TWiki::Store::readTemplate()` so that the caller simply gets an expanded template file (the same as before).
-- Directives are of the form `%TMPL:<key>%` and `%TMPL:<key>{"attr"}%`.
+- Directives are of the form <code>**%TMPL:&lt;key&gt;%**</code> and <code>**%TMPL:&lt;key&gt;\{"attr"\}%**</code>.
 - Directives:
-  - `%TMPL:INCLUDE{"file"}%`: Includes a template file. The template directory of the current web is searched first, then the templates root (`twiki/templates`).
-  - `%TMPL:DEF{"var"}%`: Define a variable. Text between this and the END directive is not returned, but put into a hash for later use.
-  - `%TMPL:END%`: Ends variable definition.
-  - `%TMPL:P{"var"}%`: Prints a previously defined variable.
-- Variables are live in a global name space, there is no parameter passing.
-- Two-pass processing, so that you can use a variable before declaring it or after.
-- Templates and [[TWikiSkins]] work transparently and interchangeably. For example, you can create a skin that overloads just the `twiki.tmpl`, like `twiki.print.tmpl`, that redefines the header and footer.
-- **_NOTE:_** The template directives work only for templates, they do not get processed in topic text.
+  - <code>**%TMPL:INCLUDE\{"file"\}%**</code>: Includes a template file. The template directory of the current web is searched first, then the templates root (`twiki/templates`).
+  - <code>**%TMPL:DEF\{"var"\}%**</code>: Define a variable. Text between this and the END directive is not returned, but put into a hash for later use.
+  - <code>**%TMPL:END%**</code>: Ends variable definition.
+  - <code>**%TMPL:P\{"var"\}%**</code>: Prints a previously defined variable.
+- Variables live in a global name space: there is no parameter passing.
+- Two-pass processing lets you use a variable before or after declaring it.
+- Templates and [[TWikiSkins]] work transparently and interchangeably. For example, you can create a skin that overloads only the `twiki.tmpl` master template, like `twiki.print.tmpl`, that redefines the header and footer.
+- %H% Use of template directives is optional: templates work without them.
+- %X% **NOTE:** Template directives work only for templates: they do not get processed in topic text.
+
+## <a name="Types of Template"></a> Types of Template
+
+There are three types of template:
+
+- **Master Template**: Stores common parts; included by other templates
+- **HTML Page Templates**: Defines the layout of %WIKITOOLNAME% pages
+- **Template Topics**: Defines default text when you create a new topic
 
-## <a name="TWiki Master Template"></a> TWiki Master Template
+### <a name="Master Templates"></a> Master Templates
 
-All common parts are defined in a master template, <code>**twiki.tmpl**</code>, that all other templates use.
+Common parts, appearing in two or more templates, can be defined in a master template and then shared by others: <code>**twiki.tmpl**</code> is the default master template.
 
 > <table border="1" cellpadding="0" cellspacing="0">
 >   <tr>
@@ -76,7 +86,7 @@ All common parts are defined in a master template, <code>**twiki.tmpl**</code>,
 >   </tr>
 >   <tr>
 >     <td> %TMPL:DEF{"standardheader"}% </td>
->     <td> Standard header (ex: view, index, seach) </td>
+>     <td> Standard header (ex: view, index, search) </td>
 >   </tr>
 >   <tr>
 >     <td> %TMPL:DEF{"simpleheader"}% </td>
@@ -92,31 +102,28 @@ All common parts are defined in a master template, <code>**twiki.tmpl**</code>,
 >   </tr>
 > </table>
 
-## <a name="Types of Template"></a> Types of Template
-
-There are two types of templates:
-
-- **HTML Page Templates**: Defines layout of %WIKITOOLNAME% pages
-- **Template Topics**: Defines default text when you create a new topic
+<a name="HtmlTemplates"></a>
 
 ### <a name="HTML Page Templates"></a> HTML Page Templates
 
-%WIKITOOLNAME% uses HTML template files for all actions like topic view, edit, preview and so on. This allows you to change the look and feel of all pages by editing just some template files.
+%WIKITOOLNAME% uses HTML template files for all actions, like topic view, edit, and preview. This allows you to change the look and feel of all pages by editing just a few template files.
 
-The template files are in the <code>**twiki/templates**</code> directory. As an example, <code>**twiki/templates/view.tmpl**</code> is the template file for the <code>**twiki/bin/view**</code> script. Templates can be overloaded per web. The following search order applies:
+Templates are in the <code>**twiki/templates**</code> directory. As an example, <code>**twiki/templates/view.tmpl**</code> is the template file for the <code>**twiki/bin/view**</code> script. Templates can be overloaded by individual webs. The following search order applies:
 
 1. <code>**twiki/templates/$webName/$scriptName.tmpl**</code>
 2. <code>**twiki/templates/$scriptName.tmpl**</code>
+  - `$webName` is the name of the web (ex: `Main`)
+  - `$scriptName` is the script (ex: `view`).
 
-**_Note:_** `$webName` is the name of the web (ex: `Main`), and <code>**$scriptName**</code> is the script (ex: `view`).
-
-**_Note:_** [[TWikiSkins]] can be defined to overload the standard templates.
+%H% **NOTE:** [[TWikiSkins]] can be defined to overload the standard templates.
 
 Special variables are used in templates, especially in `view`, to display [[meta data|Main/TWikiMetaData#MetaDataRendering]].
 
+<a name="TemplateTopics"></a>
+
 ### <a name="Template Topics"></a> Template Topics
 
-Template topics define the default text for new topics. There are three types of template topics:
+Template topics define the default text for new topics. There are three types of template topic:
 
 > <table border="1" cellpadding="0" cellspacing="0">
 >   <tr>
@@ -125,11 +132,11 @@ Template topics define the default text for new topics. There are three types of
 >   </tr>
 >   <tr>
 >     <td>[[Main/WebTopicViewTemplate]]</td>
->     <td> Help text shown when you view a non existing topic. </td>
+>     <td> Error page shown when you try to view a nonexistent topic </td>
 >   </tr>
 >   <tr>
 >     <td>[[Main/WebTopicNonWikiTemplate]]</td>
->     <td> Help text shown when you view a non existing topic that has not a [[Main/WikiName]]. </td>
+>     <td> Alert page shown when you try to view a nonexistent topic with a non-WikiName </td>
 >   </tr>
 >   <tr>
 >     <td>[[Main/WebTopicEditTemplate]]</td>
@@ -137,11 +144,11 @@ Template topics define the default text for new topics. There are three types of
 >   </tr>
 > </table>
 
-All template topics are located in the TWiki web. The [[WebTopicEditTemplate]] can be overloaded. The following search order applies when you create a new topic:
+All template topics are located in the TWiki web. The [[WebTopicEditTemplate]] can be overloaded. When you create a new topic, TWiki locates a topic to use as a content template according to the following search order:
 
-1. The topic name specified by the `templatetopic` CGI parameter.
-2. WebTopicEditTemplate in the current web.
-3. WebTopicEditTemplate in the TWiki web.
+1. A topic name specified by the `templatetopic` CGI parameter.
+2. WebTopicEditTemplate in the current web
+3. WebTopicEditTemplate in the TWiki web
 
 #### <a name="Template Topics in Action"></a> Template Topics in Action
 
@@ -153,9 +160,9 @@ Here is an example for creating new topics based on a specific template topic:
   </ul>
 </form>
 
-Above form asks for a topic name. A hidden input tag of name "templatetopic" specifies the [[ExampleTopicTemplate]] as the template topic. Here is the HTML source of the form:
+The above form asks for a topic name. A hidden input tag named <code>**templatetopic**</code> specifies [[ExampleTopicTemplate]] as the template topic to use. Here is the HTML source of the form:
 
-    <form name="new" action="%SCRIPTURLPATH%/edit%SCRIPTSUFFIX%/%WEB%/">
+    <form name="new" action="%SCRIPTURLPATH%/edit%SCRIPTSUFFIX%/%INTURLENCODE{"%WEB%"}%/">
        * New example topic:
          <input type="text" name="topic" value="ExampleTopic%SERVERTIME{$yearx$mox$day}%" size="23" />
          <input type="hidden" name="templatetopic" value="ExampleTopicTemplate" />
@@ -164,17 +171,17 @@ Above form asks for a topic name. A hidden input tag of name "templatetopic" spe
          (date format is <nop>YYYYxMMxDD)
     </form>
 
-The "onlywikiname" parameter enforces [[WikiWords]] for topic names.
+The <code>**onlywikiname**</code> parameter enforces [[WikiWords]] for topic names.
 
-**_Note:_** Use can use the `%WIKIUSERNAME%` and `%DATE%` variables in your topic templates as the signature; those variables are expanded when a new topic is created. The standard topic signature is: <br />`-- %WIKIUSERNAME% - %DATE%`
+%T% **TIP:** You can use the `%WIKIUSERNAME%` and `%DATE%` variables in your topic templates to include the signature of the person creating a new topic. The variables are expanded into fixed text when a new topic is created. The standard signature is: <br /><code>**-- %WIKIUSERNAME% - %DATE%**</code>
 
 ## <a name="Templates by Example"></a> Templates by Example
 
-Attached is an example of an oops base template `oopsbase.tmpl` and a example oops dialog `oopstest.tmpl` which is based on the base template. **_NOTE:_** This isn't the release version, just a quick, simple demo.
+Attached is an example of an oops based template `oopsbase.tmpl` and an example oops dialog `oopstest.tmpl` based on the base template. %A% **NOTE:** This isn't the release version, just a quick, simple demo.
 
 ### <a name="Base template oopsbase.tmpl"></a> Base template oopsbase.tmpl
 
-The first line declares the delimiter variable called "sep", used to separate multiple link items. The variable can be called anywhere by writing `%TMPL:P{"sep"}%`
+The first line declares a delimiter variable called "sep", used to separate multiple link items. The variable can be called anywhere by writing `%TMPL:P{"sep"}%`
 
 > <table bgcolor="#f5f5f5" border="1" cellpadding="1" cellspacing="0">
 >   <tr>
@@ -254,16 +261,16 @@ Each oops template basically just defines some variables and includes the base t
 
 ### <a name="Sample screen shot of oopstest.t"></a> Sample screen shot of oopstest.tmpl
 
-With URL: <code>**.../bin/oops/Test/TestTopic2?template=oopstest&amp;param1=WebHome&amp;param2=WebNotify**</code>
+With URL: <code>**.../bin/oops/Sandbox/TestTopic2?template=oopstest&amp;param1=WebHome&amp;param2=WebNotify**</code>
 
 > <table border="1" cellpadding="0" cellspacing="0">
 >   <tr>
->     <td><img alt="testscreen.gif" height="304" src="http://www.dementia.org/twiki//view/testscreen.gif" width="554" /></td>
+>     <td><img alt="testscreen.gif" height="304" src="http://www.dementia.org/twiki//view/testscreen.gif" width="589" /></td>
 >   </tr>
 > </table>
 
 ## <a name="Known Issues"></a> Known Issues
 
-- A drawback of referring to a master template is that you can only test a template from within TWiki, where the include variables are resolved. In the previous system, each template is a structurally complete HTML document with a `.tmpl` filename extension - it contains unresolved `%VARIABLES%`, but can still be previewed directly in a browser.
+- A drawback of referring to a master template is that you can only test a template from within TWiki, where the include variables are resolved. In the previous system, each template was a structurally complete HTML document with a `.tmpl` filename extension - it contained unresolved `%VARIABLES%`, but could still be previewed directly in a browser.
 
--- [[PeterThoeny]] - 23 Jul 2001 <br /> -- [[MikeMannix]] - 14 Sep 2001 <br />
+-- [[PeterThoeny]] - 23 Jul 2001 <br /> -- [[MikeMannix]] - 14 Sep 2001 <br /> -- TWiki:Main/DavidLeBlanc - 11 Mar 2002