Difference: TWikiTemplates (36 vs. 37)

Revision 372013-09-25 - TWikiContributor

Line: 1 to 1
 

TWiki Templates

Line: 118 to 118
 TIP Tip: If you want to override existing templates, without having to worry that your changes will get overwritten by the next TWiki update, change the {TemplatePath} so that another directory, such as the %USERSWEB% appears at the front. You can then put your own templates into that directory or web and these will override the standard templates. (Note that such will increase the lookup time for templates by searching your directory first.)

Changed:
<
<

TMPL:INCLUDE recursion for piecewise customisation, or mixing in new features

>
>

TMPL:INCLUDE recursion for piecewise customization, or mixing in new features

  If there is recursion in the TMPL:INCLUDE chain (eg twiki.classic.tmpl contains %TMPL:INCLUDE{"twiki"}%, the templating system will include the next twiki.SKIN in the skin path.
Changed:
<
<
For example, to create a customisation of pattern skin, where you only want to over-ride the breadcrumbs for the view script, you can create only a view.yourlocal.tmpl:
>
>
For example, to create a customization of pattern skin, where you only want to over-ride the breadcrumbs for the view script, you can create only a view.yourlocal.tmpl:
 
%TMPL:INCLUDE{"view"}%
%TMPL:DEF{"breadcrumb"}% We don't want any crumbs %TMPL:END%
Line: 199 to 199
 %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:
<
<

3. Control over variable expansion

>
>

3. Causing variable expansion in a section

  You can forcefully expand TWikiVariables by placing them inside a type="expandvariables" section in the template topic, such as:
Line: 229 to 229
 
Added:
>
>

4. Specifying variables to be expanded individually

You may want to mix variables to be expanded and variables not to be. By prepending a variable name with EOTC__ (EOTC followed by two underscores; EOTC stands for Expand On Topic Creation), you can have the variable expanded.

Here's an example.

%EOTC__SEARCH{"."
 topic="%URLPARAM{prefix}%*"
 nonoise="on"
 format="$percntINCLUDE{$topic}$percnt" separator="$n"
}%
This yields a series of %INCLUDE{...}%s, which are not expanded. This is not achievable by an expandvariables section.
 

Specifying a Form

Line: 265 to 281
  Here is an example for creating new topics (in the Sandbox web) based on a specific template topic and form:
Changed:
<
<
>
>
 
  • New example topic:
Changed:
<
<
 
>
>

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 raw text of the form:

%EDITFORMFIELD{ "new" type="start" action="edit" topic="Sandbox.%TOPIC%" }%
   * New example topic: 
     %EDITFORMFIELD{ "topic" type="text" value="ExampleTopicAUTOINC0001" size="30" }%
     %EDITFORMFIELD{ "templatetopic" type="hidden" value="%SYSTEMWEB%.ExampleTopicTemplate" }%
     %EDITFORMFIELD{ "topicparent" type="hidden" value="%HOMETOPIC%" }%
     %EDITFORMFIELD{ "onlywikiname" type="hidden" value="on" }%
     %EDITFORMFIELD{ "onlynewtopic" type="hidden" value="on" }%
     %EDITFORMFIELD{ "form" type="submit" value="Create" }%
%EDITFORMFIELD{ "form" type="end" }%
 
Changed:
<
<
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:
>
>
Here is the equivalent form using a hand-crafted HTML form:
 

Changed:
<
<
<form name="new" action="%SCRIPTURLPATH{edit}%/Sandbox/">
>
>
<form name="new" action="%SCRIPTURLPATH{edit}%/Sandbox/%HOMETOPIC%">
 
  • New example topic: <input type="text" name="topic" value="ExampleTopicAUTOINC0001" size="30" />
Changed:
<
<
<input type="hidden" name="templatetopic" value="ExampleTopicTemplate" /> <input type="hidden" name="topicparent" value="%TOPIC%" />
>
>
<input type="hidden" name="templatetopic" value="%SYSTEMWEB%.ExampleTopicTemplate" /> <input type="hidden" name="topicparent" value="%HOMETOPIC%" />
  <input type="hidden" name="onlywikiname" value="on" /> <input type="hidden" name="onlynewtopic" value="on" /> <input type="submit" class="twikiSubmit" value="Create" /> </form>
Changed:
<
<
ALERT! Note: You can create a topic in one step, without going through the edit screen. To do that, specify the save script instead of the edit script in the form action. When you specify the save script you have to use the "post" method. Example:
>
>
ALERT! Note: You can create a topic in one step, without going through the edit screen. To do that, specify the save script instead of the edit script in the form action. When you specify the save script in an HTML form tag you have to use the "post" method. This is done automatically when using the EDITFORMFIELD variable. Example when using the HTML form tag:
 
<form name="new" action="%SCRIPTURLPATH{save}%/Sandbox/" method="post">
    ...

 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 1999-2024 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.