Ignore:
Timestamp:
11/09/08 15:46:31 (4 years ago)
Author:
CrawfordCurrie
Message:

Item109: topic renamings, and TWiki.spec updates to match

File:
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/core/data/TWiki/PresentationTemplates.txt

    r14 r484  
    1 %META:TOPICINFO{author="TWikiContributor" date="1210999363" format="1.1" version="$Rev: 16186 $"}% 
     1%META:TOPICINFO{author="ProjectContributor" date="1111931141" format="1.0" version="$Rev: 15508 $"}% 
    22%STARTINCLUDE% 
    3 ---+ TWiki Templates 
     3---+ Presentation Templates 
    44 
    5 _Definition of the templates used to render all HTML pages displayed in TWiki_  
     5_Definition of the templates used to render output_  
    66 
    77%TOC% 
     
    99---++ Overview 
    1010 
    11 _Templates_ are plain text with embedded _template directives_ that tell TWiki how to compose blocks of text together, to create something new. 
    12  
    13 There are two types of template: 
    14    * *Master Templates*: Define the HTML used to display TWiki pages. 
    15    * *Template Topics*: Define default text when you create a new topic 
    16  
    17 __%T% Tip:__ TWiki:TWiki.TWikiTemplatesSupplement on TWiki.org has supplemental documentation on TWiki templates. 
     11_Presentation Templates_ are plain text with embedded _template macros_ that describe 
     12how to compose blocks of text together, to create something new. 
    1813 
    1914#HtmlTemplates 
    20 ---++ Master Templates 
    21 TWiki uses master templates when composing the output from all actions, like topic view, edit, and preview. 
     15Presentation templates are used composing the output from all actions, like view, edit, and preview. 
    2216This allows you to change the look and feel of all pages by editing just a few template files. 
    2317 
    24 Master templates are also used in the definition of TWikiSkins. 
     18Presentation templates are also used in the definition of [[Skins]]. 
    2519 
    26 Master templates are stored as text files with the extension =.tmpl=. 
    27 They are usually HTML with embedded _template directives_. 
    28 The directives are expanded when TWiki wants to generate a user interface screen. 
     20Presentation templates are usually stored as text files with the extension 
     21=.tmpl=, though can also come from topic text in some limited circumstances. 
     22They are usually HTML with embedded _template macros_. 
     23The macros are expanded when we wants to generate output, 
     24such as a user interface screen. 
    2925 
    30 #TemplateVariables 
     26#TemplateMacros 
    3127---+++ How Template Directives Work 
    3228   * Directives are of the form ==%<nop>TMPL:&lt;key&gt;%== and ==%<nop>TMPL:&lt;key&gt;{"attr"}%==. 
     
    3834      * ==%<nop>{...}%==: is a comment. 
    3935   * Two-pass processing lets you use a variable before or after declaring it. 
    40    * 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. 
    41    * %H% Use of template directives is optional: templates work without them. 
    42    * %X% *NOTE:* Template directives work only for templates: they do not get processed in normal topic text. 
     36   * PresentationTemplates and [[Skins]] work transparently and interchangeably. For example, you can create a skin that overloads only the =twiki.tmpl= master presentation template, like =twiki.print.tmpl=, that redefines the header and footer. 
     37   * %H% Use of template macros is optional: templates work without them. 
     38   * %X% *NOTE:* Most template macros work only for templates: they do not get processed in normal topic text. The one exception is =%TMPL:P=. 
    4339 
    4440TMPL:P also supports simple parameters. For example, given the definition 
     
    4844 
    4945Any alphanumeric characters can be used in parameter names. 
    50 You are highly recommended to use parameter names that cannot be confused with TWikiVariables. 
     46You are highly recommended to use parameter names that cannot be confused with [[Macros]]. 
    5147 
    5248Note that three parameter names, =context=, =then= and =else= are *reserved*. 
    53 They are used to support a limited form of "if" condition that you can use to select which of two templates to use, based on a _context identifier_: 
     49They are used to support a limited form of "if" condition that you can use to select which of two TMPL:DEFs to use, based on a _context identifier_: 
    5450<verbatim> 
    5551%TMPL:DEF{"link_inactive"}%<input type="button" disabled value="Link>%TMPL:END% 
     
    5753%TMPL:P{context="inactive" then="inactive_link" else="active_link"}% for %CONTEXT% 
    5854</verbatim> 
    59 When the "inactive" context is set, then this will expand the "link_inactive" template; otherwise it will expand the "link_active" template. 
     55When the "inactive" context is set, then this will expand the "link_inactive" TMPL:DEF; otherwise it will expand the "link_active" TMPL:DEF. 
    6056See IfStatements for details of supported context identifiers. 
    6157 
    62 ---+++ Finding Templates 
     58---+++ Finding Presentation Templates 
    6359 
    64 The master templates shipped with a twiki release are stored in the twiki/templates directory. 
    65 As an example, ==twiki/templates/view.tmpl== is the default template file for the ==twiki/bin/view== script.  
     60The presentation templates shipped with a release are stored in the twiki/templates directory. 
     61As an example, ==twiki/templates/view.tmpl== is the default presentation template file for the ==twiki/bin/view== script.  
    6662 
    6763You can save templates in other directories as long as they are listed in the ={TemplatePath}= configuration setting. 
    6864The ={TemplatePath}= is defined in the Miscellaneous section of the [[%SCRIPTURLPATH{configure}%][configure]] page. 
    6965 
    70 You can also save templates in user topics (_IF_ there is no possible template match in the =templates= directory). 
     66You can also save presentation templates in user topics (_IF_ there is no possible template match in the =templates= directory). 
    7167The ={TemplatePath}= configuration setting defines which topics will be accepted as templates. 
    7268 
    73 Templates that are included with an explicit ='.tmpl'= extension are looked for only in the =templates/= directory. 
     69Presentation Templates that are included with an explicit ='.tmpl'= extension are looked for only in the =templates/= directory. 
    7470For instance =%TMPL:INCLUDE{"example.tmpl"}%= will only return =templates/example.tmpl=, regardless of ={TemplatePath}= and SKIN settings. 
    7571 
    7672The out-of-the-box setting of ={TemplatePath}= supports the following search order to determine which template file or topic to use for a particular script or =%TMPL:INCLUDE{"script"}%= statement. 
    77 The _skin path_ is set as described in TWikiSkins. 
     73The _skin path_ is set as described in [[Skins]]. 
    7874 
    7975   1 templates/%RED%web%ENDCOLOR%/%RED%script%ENDCOLOR%.%RED%skin%ENDCOLOR%.tmpl for each %RED%skin%ENDCOLOR% on the skin path 
    80       * %X% this usage is supported *for compatibility only* and is *deprecated*. Store web-specific templates in TWiki topics instead. 
     76      * %X% this usage is supported *for compatibility only* and is *deprecated*. Store web-specific templates in topics instead. 
    8177   1 templates/%RED%script%ENDCOLOR%.%RED%skin%ENDCOLOR%.tmpl for each %RED%skin%ENDCOLOR% on the skin path 
    8278   1 templates/%RED%web%ENDCOLOR%/%RED%script%ENDCOLOR%.tmpl 
    83       * %X% this usage is supported *for compatibility only* and is *deprecated*. Store web-specific templates in TWiki topics instead. 
     79      * %X% this usage is supported *for compatibility only* and is *deprecated*. Store web-specific templates in topics instead. 
    8480   1 templates/%RED%script%ENDCOLOR%.tmpl 
    85    1 The TWiki topic aweb.atopic if the template name can be parsed into aweb.atopic 
    86    1 The TWiki topic %RED%web%ENDCOLOR%.%RED%Skin%ENDCOLOR%Skin%RED%Script%ENDCOLOR%Template for each %RED%skin%ENDCOLOR% on the skin path 
    87    1 The TWiki topic %RED%web%ENDCOLOR%.%RED%Script%ENDCOLOR%Template 
    88    1 The TWiki topic %<nop>SYSTEMWEB%.%RED%Skin%ENDCOLOR%Skin%RED%Script%ENDCOLOR%Template for each %RED%skin%ENDCOLOR% on the skin path 
    89    1 The TWiki topic %<nop>SYSTEMWEB%.%RED%Script%ENDCOLOR%Template 
     81   1 The topic aweb.atopic if the template name can be parsed into aweb.atopic 
     82   1 The topic %RED%web%ENDCOLOR%.%RED%Skin%ENDCOLOR%Skin%RED%Script%ENDCOLOR%Template for each %RED%skin%ENDCOLOR% on the skin path 
     83   1 The topic %RED%web%ENDCOLOR%.%RED%Script%ENDCOLOR%Template 
     84   1 The topic %<nop>SYSTEMWEB%.%RED%Skin%ENDCOLOR%Skin%RED%Script%ENDCOLOR%Template for each %RED%skin%ENDCOLOR% on the skin path 
     85   1 The topic %<nop>SYSTEMWEB%.%RED%Script%ENDCOLOR%Template 
    9086*Legend:* 
    9187   * %RED%script%ENDCOLOR% refers to the script name, e.g =view=, =edit= 
     
    110106   I. =%SYSTEMWEB%.ExampleTemplate= 
    111107 
    112 Template names are usually derived from the name of the currently executing script; however it is also possible to override these settings in the =view= and =edit= scripts, for example when a topic-specific template is required. Two preference variables can be used to override the templates used: 
     108Template names are usually derived from the name of the currently executing script; however it is also possible to override these settings in the =view= and =edit= scripts, for example when a topic-specific template is required. Two preference variables can be used to override the presentation templates used: 
    113109   * =VIEW_TEMPLATE= sets the template to be used for viewing a topic 
    114110   * =EDIT_TEMPLATE= sets the template for editing a topic. 
    115 If these preferences are set locally (using _Local_ instead of _Set_) for a topic, in WebPreferences, in [[%LOCALSITEPREFS%]], or [[%SYSTEMWEB%.TWikiPreferences]] (using _Set_), the indicated templates will be chosen for =view= and =edit= respectively. The template search order is as specified above. 
     111If these preferences are set locally (using _Local_ instead of _Set_) for a topic, in WebPreferences, in [[%LOCALSITEPREFS%]], or [[%SYSTEMWEB%.DefaultPreferences]] (using _Set_), the indicated templates will be chosen for =view= and =edit= respectively. The template search order is as specified above. 
    116112 
    117113---+++ TMPL:INCLUDE recursion for piecewise customisation, or mixing in new features 
     
    138134| =%<nop>TMPL:DEF{"standardfooter"}%= | Footer, excluding revision and copyright parts | 
    139135 
    140 #TemplateTopics 
    141 ---++ Template Topics 
    142  
    143 The second type of template in TWiki are template topics. Template topics define the default text for new topics. There are four types of template topic: 
    144  
    145 | *Topic Name:* | *What it is:* | 
    146 | WebTopicViewTemplate | Alert page shown when you try to view a nonexistent topic. This page is usually used as a prompt to help you create a new topic. | 
    147 | WebTopicNonWikiTemplate | Alert page shown when you try to view a nonexistent topic with a non-WikiName. Again, this page is used as a prompt to help you create the new topic. | 
    148 | WebTopicEditTemplate | Default text used in a new topic. | 
    149 | &lt;MyCustomNamed&gt;Template | Whenever you create a topic ending in the word "Template", it is automatically added to the list of available templates in the "Use Template" drop down field on the !WebCreateNewTopic page. | 
    150  
    151 When you create a new topic using the =edit= script, TWiki locates a topic to use as a content template according to the following search order: 
    152    1 A topic name specified by the =templatetopic= CGI parameter 
    153       * if no web is specified, the current web is searched first and then the %SYSTEMWEB% web 
    154    1 <nop>WebTopicEditTemplate in the current web 
    155    1 <nop>WebTopicEditTemplate in the %SYSTEMWEB% web 
    156  
    157 #TemplateTopicsVars 
    158 ---+++ Variable Expansion 
    159  
    160 When the following variables are used in a template topic, they automatically get expanded when new topic is created based on it: 
    161  
    162 | *Variable:* | *Description:* | 
    163 | =%<nop>DATE%= | Signature format date. See VarDATE | 
    164 | =%<nop>GMTIME%= | Date/time. See VarGMTIME | 
    165 | =%<nop>GMTIME{...}%= | Formatted date/time. See VarGMTIME2 | 
    166 | =%<nop>NOP%= | A no-operation variable that gets removed. Useful to prevent a SEARCH from hitting an edit template topic; also useful to escape a variable, such as =%<nop>URLPA%<nop>NOP%RAM{...}%= escaping URLPARAM | 
    167 | =%<nop>STARTSECTION{type="templateonly"}%%BR%...%BR%%<nop>ENDSECTION{type="templateonly"}%= | Text that gets removed when a new topic based on the template is created. See notes below. | 
    168 | =%<nop>SERVERTIME%= | Date/time. See VarSERVERTIME | 
    169 | =%<nop>SERVERTIME{...}%= | Formatted date/time. See VarSERVERTIME2 | 
    170 | =%<nop>USERNAME%= | Login name of user who is instantiating the new topic, e.g. %USERNAME% | 
    171 | =%<nop>URLPARAM{"name"}%= | Value of a named URL parameter | 
    172 | =%<nop>WIKINAME%= | WikiName of user who is instantiating the new topic, e.g. <nop>%WIKINAME% | 
    173 | =%<nop>WIKIUSERNAME%= | User name of user who is instantiating the new tpoic, e.g. <nop>%WIKIUSERNAME% | 
    174  
    175 =%<nop>STARTSECTION{type="templateonly"}%%BR%...%BR%%<nop>ENDSECTION{type="templateonly"}%= markers are used to embed text that you _do not_ want expanded when a new topic based on the template topic is created. For example, you might want to write in the template topic: 
    176 <pre> 
    177 %<nop>STARTSECTION{type="templateonly"}% 
    178 This template can only be changed by: 
    179    * Set <nop>ALLOWTOPICCHANGE = <nop>%USERSWEB%.TWikiAdminGroup 
    180 %<nop>ENDSECTION{type="templateonly"}% 
    181 </pre> 
    182 This will restrict who can edit the template topic, but will get removed when a new topic based on that template topic is created. 
    183  
    184 =%<nop>NOP%= can be used to prevent expansion of TWiki variables that would otherwise be expanded during topic creation e.g.i escape =%<nop>SERVERTIME%= with =%<nop>SER%<nop>NOP%VERTIME%=. 
    185  
    186 All other variables are unchanged, e.g. are carried over "as is" into the new topic. 
    187  
    188 ---+++ Specifying a Form 
    189 When you create a new topic based on a template, you often want the new topic to have a form attached to it. You can attach a form to the template topic, in which case it will be copied into the new topic. 
    190  
    191 Sometimes this isn't quite what you want, as it copies all the existing data from the template topic into the new topic. To avoid this and use the default values specified in the form definition instead, you can use the =formtemplate= CGI parameter to the =edit= script to specify the name of a form to attach. 
    192  
    193 See TWikiScripts for information about all the other parameters to =edit=. 
    194  
    195 #AutomaticallyGeneratedTopicname 
    196 ---+++ Automatically Generated Topic Names 
    197  
    198 For TWiki applications it is useful to be able to automatically generate unique topicnames, such as !BugID0001, !BugID0002, etc. You can add =AUTOINC&lt;n&gt;= to the topic name in the edit and save scripts, and it will be replaced with an auto-incremented number on topic save. =&lt;n&gt;= is a number starting from 0, and may include leading zeros. Leading zeros are used to zero-pad numbers so that auto-incremented topic names can sort properly. Deleted topics are not re-used to ensure uniqueness of topic names. That is, the auto-incremented number is always higher than the existing ones, even if there are gaps in the number sequence. 
    199  
    200 *Examples:* 
    201    * =BugAUTOINC0= - creates topic names =Bug0=, =Bug1=, =Bug2=, ... (does not sort properly) 
    202    * =ItemAUTOINC0000= - creates topic names =Item0000=, =Item0001=, =Item0002=, ... (sorts properly up to 9999) 
    203    * =DocIDAUTOINC10001= - start with =DocID10001=, =DocID10002=, ... (sorts properly up to 99999; auto-links) 
    204  
    205 Example link to create a new topic:%BR% 
    206 <verbatim> 
    207 [[%SCRIPTURLPATH{edit}%/%WEB%/BugIDAUTOINC00001?templatetopic=BugTemplate;topicparent=%TOPIC%;t=%SERVERTIME{"$day$hour$min$sec"}%][Create new item]] 
    208 </verbatim> 
    209  
    210 ---+++ Template Topics in Action 
    211  
    212 Here is an example for creating new topics (in the Sandbox web) based on a specific template topic and form: 
    213  
    214 <form name="new" action="%SCRIPTURLPATH{edit}%/Sandbox/"> 
    215    * New example topic:  
    216      <input type="text" name="topic" value="ExampleTopicAUTOINC0001" size="30" />&nbsp;<input type="submit" class="twikiSubmit" value="Create" /> 
    217      <input type="hidden" name="templatetopic" value="ExampleTopicTemplate" /> 
    218      <input type="hidden" name="topicparent" value="%TOPIC%" /> 
    219      <input type="hidden" name="onlywikiname" value="on" /> 
    220      <input type="hidden" name="onlynewtopic" value="on" /> 
    221 </form> 
    222  
    223 The above form asks for a topic name. A hidden input tag named ==templatetopic== specifies ExampleTopicTemplate as the template topic to use. Here is the HTML source of the form: 
    224  
    225 <pre> 
    226 &lt;form name="new" action="%<nop>SCRIPTURLPATH{edit}%/Sandbox/"&gt; 
    227    * New example topic:  
    228      &lt;input type="text" name="topic" value="ExampleTopicAUTOINC0001" size="30" /&gt; 
    229      &lt;input type="hidden" name="templatetopic" value="ExampleTopicTemplate" /&gt; 
    230      &lt;input type="hidden" name="topicparent" value="%<nop>TOPIC%" /&gt; 
    231      &lt;input type="hidden" name="onlywikiname" value="on" /&gt; 
    232      &lt;input type="hidden" name="onlynewtopic" value="on" /&gt; 
    233      &lt;input type="submit" class="twikiSubmit" value="Create" /&gt; 
    234 &lt;/form&gt; 
    235 </pre> 
    236  
    237 See TWikiScripts#edit for details of the parameters that the =edit= script understands. 
    238  
    239 %T% *TIP:* You can use the =%<nop>WIKIUSERNAME%= and =%<nop>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 /> 
    240 ==-- %<nop>WIKIUSERNAME% - %<nop>DATE%== 
    241  
    242 ---+++ Using Absolute vs Relative URLs in Templates 
    243  
    244 When you use TWikiVariables such as %<nop>PUBURL% and %<nop>PUBURLPATH% in templates you should be aware that using %<nop>PUBURL% instead of %<nop>PUBURLPATH% puts absolute URLs in the produced HTML. This means that when a user saves a TWiki page in HTML and emails the file to someone outside a company firewall, the receiver has a severe problem viewing it. It is therefore recommended always to use the %<nop>PUBURLPATH% to refer to images, CSS, Javascript files etc so links become relative. This way browsers just give up right away and show a usable html file. 
    245  
    246 __Related Topics:__ TWikiSkins, DeveloperDocumentationCategory, AdminDocumentationCategory 
     136__Related Topics:__ [[Skins]] 
    247137 
    248138%STOPINCLUDE% 
    249 -- __Contributors:__ TWiki:Main.PeterThoeny, TWiki:Main.MikeMannix, TWiki:Main.DavidLeBlanc, TWiki:Main.CrawfordCurrie 
Note: See TracChangeset for help on using the changeset viewer.