Difference: TWikiTemplates (30 vs. 31)

Revision 312009-01-31 - TWikiContributor

Line: 1 to 1
 

TWiki Templates

Line: 157 to 157
 

Variable Expansion

Changed:
<
<
When the following variables are used in a template topic, they automatically get expanded when new topic is created based on it:
>
>
TWikiVariables located in template topics get expanded as follows when a new topic is created.
 
Added:
>
>

1. Default variable expansion

The following variables used in a template topic automatically get expanded when new topic is created based on it:

 
Variable: Description:
%DATE% Signature format date. See VarDATE
%GMTIME% Date/time. See VarGMTIME
Line: 168 to 173
 
%SERVERTIME% Date/time. See VarSERVERTIME
%SERVERTIME{...}% Formatted date/time. See VarSERVERTIME2
%USERNAME% Login name of user who is instantiating the new topic, e.g. guest
Changed:
<
<
%URLPARAM{"name"}% Value of a named URL parameter
>
>
%URLPARAM{"name"}% Value of a named URL parameter. See VarURLPARAM.
 
%WIKINAME% WikiName of user who is instantiating the new topic, e.g. TWikiGuest
%WIKIUSERNAME% User name of user who is instantiating the new tpoic, e.g. Main.TWikiGuest
Changed:
<
<
%STARTSECTION{type="templateonly"}%
...
%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:
>
>

2. Preventing variable expansion

In a template topic, embed text that you do not want expanded inside a %STARTSECTION{type="templateonly"}% ... %ENDSECTION{type="templateonly"}% section. For example, you might want to write this in the template topic:

 
%STARTSECTION{type="templateonly"}%
This template can only be changed by:
   * Set ALLOWTOPICCHANGE = Main.TWikiAdminGroup
%ENDSECTION{type="templateonly"}%
Changed:
<
<
This will restrict who can edit the template topic, but will get removed when a new topic based on that template topic is created.
>
>
This will restrict who can edit the template topic, but will be removed when a new topic based on that template topic is created.
 
Changed:
<
<
%NOP% can be used to prevent expansion of TWiki variables that would otherwise be expanded during topic creation e.g.i escape %SERVERTIME% with %SER%NOP%VERTIME%.
>
>
%NOP% can be used to prevent expansion of TWiki variables that would otherwise be expanded during topic creation. For example, escape %SERVERTIME% with %SER%NOP%VERTIME%.
 
Changed:
<
<
All other variables are unchanged, e.g. are carried over "as is" into the new topic.
>
>

3. Control over variable expansion

 
Added:
>
>
You can forcefully expand TWikiVariables by placing them inside a type="expandvariables" section in the template topic, such as:
%STARTSECTION{ type="expandvariables" }% ... %ENDSECTION{ type="expandvariables" }% 

Example:

If you have the following content in a template topic:

%STARTSECTION{ type="expandvariables" }%
   * %TWIKIWEB%.ATasteOfTWiki - view a short introductory presentation on TWiki for beginners
   * %TWIKIWEB%.WelcomeGuest - starting points on TWiki
   * %TWIKIWEB%.TWikiUsersGuide - complete TWiki documentation
   * Sandbox.%HOMETOPIC% - try out TWiki on your own
   * Sandbox.%TOPIC%Sandbox - just for me
%ENDSECTION{ type="expandvariables" }%

you will get this raw text in new topics based on that template topic:

   * TWiki.ATasteOfTWiki - view a short introductory presentation on TWiki for beginners
   * TWiki.WelcomeGuest - starting points on TWiki
   * TWiki.TWikiUsersGuide - complete TWiki documentation
   * Sandbox.WebHome - try out TWiki on your own
   * Sandbox.JimmyNeutronSandbox - just for me

 

Specifying a Form

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.

Line: 246 to 285
 Related Topics: TWikiSkins, DeveloperDocumentationCategory, AdminDocumentationCategory
Changed:
<
<
-- Contributors: TWiki:Main.PeterThoeny, TWiki:Main.MikeMannix, TWiki:Main.DavidLeBlanc, TWiki:Main.CrawfordCurrie
>
>
-- Contributors: TWiki:Main.PeterThoeny, TWiki:Main.MikeMannix, TWiki:Main.DavidLeBlanc, TWiki:Main.CrawfordCurrie, TWiki:Main.SopanShewale
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 1999-2026 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback
Note: Please contribute updates to this topic on TWiki.org at TWiki:TWiki.TWikiTemplates.