Difference: TWikiTemplates (35 vs. 36)

Revision 362012-05-17 - TWikiContributor

Line: 1 to 1
 

TWiki Templates

Line: 59 to 59
 When the "inactive" context is set, then this will expand the "link_inactive" template; otherwise it will expand the "link_active" template. See IfStatements for details of supported context identifiers.
Added:
>
>
 

Finding Templates

The master templates shipped with a twiki release are stored in the twiki/templates directory.

Line: 116 to 117
  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.)
Added:
>
>
 

TMPL:INCLUDE recursion for piecewise customisation, 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.

Line: 128 to 130
  The default {TemplatePath} will not give you the desired result if you put these statements in the topic Thisweb.YourlocalSkinViewTemplate. The default {TemplatePath} will resolve the request to the template/view.pattern.tmpl, before it gets to the Thisweb.YourlocalSkinViewTemplate resolution. You can make it work by prefixing the {TemplatePath} with: $web.YourlocalSkin$nameTemplate.
Added:
>
>
 

Default master template

twiki.tmpl is the default master template. It defines the following sections.

Line: 158 to 161
 
  1. WebTopicEditTemplate in the TWiki web

Added:
>
>
 

Variable Expansion

TWikiVariables located in template topics get expanded as follows when a new topic is created.

Line: 244 to 248
 
  • ItemAUTOINC0000 - creates topic names Item0000, Item0001, Item0002, ... (sorts properly up to 9999)
  • DocIDAUTOINC10001 - start with DocID10001, DocID10002, ... (sorts properly up to 99999; auto-links)
Added:
>
>
Characters after AUTOINC<n> are preserved, but are not taken into account when calculating the next increment. Use this to create topic names that have a unique identifier (serial number) and a descriptive text.

Example:

  • BlogAUTOINC0001-my-first-blog - creates topic name Blog0001-my-first-blog
  • BlogAUTOINC0001-my-crazy-cats - creates topic name Blog0002-my-crazy-cats
  • BlogAUTOINC0001-fondue-recipe - creates topic name Blog0003-fondue-recipe
 Example link to create a new topic:
[[%SCRIPTURLPATH{edit}%/%WEB%/BugIDAUTOINC00001?templatetopic=BugTemplate;topicparent=%TOPIC%;t=%SERVERTIME{"$day$hour$min$sec"}%][Create new item]]
Added:
>
>
 

Template Topics in Action

Here is an example for creating new topics (in the Sandbox web) based on a specific template topic and form:

Line: 288 to 300
 TIP 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:
-- %WIKIUSERNAME% - %DATE%
Added:
>
>
 

Using Absolute vs Relative URLs in Templates

When you use TWikiVariables such as %PUBURL% and %PUBURLPATH% in templates you should be aware that using %PUBURL% instead of %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 %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.

 
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.