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.
1. Default variable expansionThe following variables used in a template topic automatically get expanded when new topic is created based on it: | |||||||
| ||||||||
Line: 168 to 173 | ||||||||
| ||||||||
Changed: | ||||||||
< < |
| |||||||
> > |
| |||||||
| ||||||||
Changed: | ||||||||
< < | %STARTSECTION{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"}% 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% . | |||||||
> > |
3. Control over variable expansion | |||||||
Changed: | ||||||||
< < | All other variables are unchanged, e.g. are carried over "as is" into the new topic. | |||||||
> > | 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" }% | |||||||
Added: | ||||||||
> > | 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 | ||||||||
Added: | ||||||||
> > | ||||||||
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.
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 | ||||||||
Line: 246 to 285 | ||||||||
Related Topics: TWikiSkins, DeveloperDocumentationCategory, AdminDocumentationCategory | ||||||||
Changed: | ||||||||
< < | -- Contributors: TWiki:Main.PeterThoeny![]() ![]() ![]() ![]() | |||||||
> > | -- Contributors: TWiki:Main.PeterThoeny![]() ![]() ![]() ![]() ![]() |