
On this page:
TWiki Template SystemDefinition of the templates used to render all HTML pages displayed in TWikiOverview | |||||||||||||||
| Changed: | |||||||||||||||
| < < | The new modular template system is more flexible, efficient, and easily updated than the old set-up, where each template is a complete HTML file. The new master template approach places common templates parts, like headers and footers, in one shared file. This simplifies the conversion of templates into XHTML format, and provides a more versatile solution for templates and for skins. | ||||||||||||||
| > > | The new modular template system is more flexible, efficient, and easily updated than the old set-up, where each template is a complete HTML file. The new master template approach places common templates parts, like headers and footers, in one shared file. This simplifies the conversion of templates into XHTML format, and provides a more versatile solution for templates and for TWikiSkins. | ||||||||||||||
Major changes from the previous template systemThe main difference is that templates are now defined using variables to include template parts. You change one stored instance of a common element to update all occurrences. The new system:
Functional Specifications
| |||||||||||||||
| Changed: | |||||||||||||||
| < < |
| ||||||||||||||
| > > |
| ||||||||||||||
| |||||||||||||||
| Deleted: | |||||||||||||||
| < < |
| ||||||||||||||
| |||||||||||||||
| Changed: | |||||||||||||||
| < < |
| ||||||||||||||
| > > |
| ||||||||||||||
New Template System by ExampleAttached is an example of an oops base templateoopsbase.tmpl and a example oops dialog oopstest.tmpl which is based on the base template. NOTE: This isn't the release version, just a quick, simple demo.
Base template oopsbase.tmplThe first line declares the delimiter variable called "sep", used to separate multiple link items. The variable can be called anywhere by writing%TMPL:P{"sep"}% | |||||||||||||||
| Deleted: | |||||||||||||||
| < < | NOTE: Added a dot to escape rendering of variables, i.e. read %.WEB% as %WEB%. | ||||||||||||||
| Added: | |||||||||||||||
| > > | |||||||||||||||
| Changed: | |||||||||||||||
| < < | <table border="1" cellspacing="0" cellpadding="1"> | ||||||||||||||
| > > | %TMPL:DEF{"sep"}% | %TMPL:END% | ||||||||||||||
| Deleted: | |||||||||||||||
| < < | <tr><td> <verbatim> %.TMPL:DEF{"sep"}% | %.TMPL:END% | ||||||||||||||
| <html> <head> | |||||||||||||||
| Changed: | |||||||||||||||
| < < | <title> %.WIKITOOLNAME% . %.WEB% . %.TOPIC% %.TMPL:P{"titleaction"}%</title> <base href="%.SCRIPTURL%/view%.SCRIPTSUFFIX%/%.WEB%/%.TOPIC%"> | ||||||||||||||
| > > | <title> %WIKITOOLNAME% . %WEB% . %TOPIC% %.TMPL:P{"titleaction"}%</title> <base href="%SCRIPTURL%/view%SCRIPTSUFFIX%/%WEB%/%TOPIC%"> | ||||||||||||||
| <meta name="robots" content="noindex"> </head> <body bgcolor="#FFFFFF"> <table width="100%" border="0" cellpadding="3" cellspacing="0"> <tr> | |||||||||||||||
| Changed: | |||||||||||||||
| < < | <td bgcolor="%.WEBBGCOLOR%" rowspan="2" valign="top" width="1%"> <a href="%.WIKIHOMEURL%"> <img src="%.PUBURLPATH%/wikiHome.gif" border="0"></a> | ||||||||||||||
| > > | <td bgcolor="%WEBBGCOLOR%" rowspan="2" valign="top" width="1%"> <a href="%WIKIHOMEURL%"> <img src="%PUBURLPATH%/wikiHome.gif" border="0"></a> | ||||||||||||||
| </td> <td> | |||||||||||||||
| Changed: | |||||||||||||||
| < < | <b>%.WIKITOOLNAME% . %.WEB% . </b><font size="+2"> <B>%.TOPIC%</b> %.TMPL:P{"titleaction"}%</font> | ||||||||||||||
| > > | <b>%WIKITOOLNAME% . %WEB% . </b><font size="+2"> <B>%TOPIC%</b> %TMPL:P{"titleaction"}%</font> | ||||||||||||||
| </td> </tr> | |||||||||||||||
| Changed: | |||||||||||||||
| < < | <tr bgcolor="%.WEBBGCOLOR%"> | ||||||||||||||
| > > | <tr bgcolor="%WEBBGCOLOR%"> | ||||||||||||||
| <td colspan="2"> | |||||||||||||||
| Changed: | |||||||||||||||
| < < | %.TMPL:P{"webaction"}% | ||||||||||||||
| > > | %TMPL:P{"webaction"}% | ||||||||||||||
| </td> </tr> </table> | |||||||||||||||
| Changed: | |||||||||||||||
| < < | ++ %.TMPL:P{"heading"}% %.TMPL:P{"message"}% | ||||||||||||||
| > > | ++ %TMPL:P{"heading"}% %TMPL:P{"message"}% | ||||||||||||||
| <table width="100%" border="0" cellpadding="3" cellspacing="0"> | |||||||||||||||
| Changed: | |||||||||||||||
| < < | <tr bgcolor="%.WEBBGCOLOR%"> | ||||||||||||||
| > > | <tr bgcolor="%WEBBGCOLOR%"> | ||||||||||||||
| <td valign="top"> | |||||||||||||||
| Changed: | |||||||||||||||
| < < | Topic <b>TWikiTemplates</b> . { %.TMPL:P{"topicaction"}% | ||||||||||||||
| > > | Topic <b>%TOPIC%</b> . { %TMPL:P{"topicaction"}% | ||||||||||||||
| } </td> </tr> </table> </body> | |||||||||||||||
| Deleted: | |||||||||||||||
| < < | </verbatim> </td></tr> </table > | ||||||||||||||
| Added: | |||||||||||||||
| > > | |||||||||||||||
Test template oopstest.tmplEach oops template basically just defines some variables and includes the base template that does the layout work. | |||||||||||||||
| Changed: | |||||||||||||||
| < < |
%.TMPL:DEF{"titleaction"}% (test =titleaction=) %.TMPL:END%
%.TMPL:DEF{"webaction"}% test =webaction= %.TMPL:END%
%.TMPL:DEF{"heading"}%
Test heading %.TMPL:END%
%.TMPL:DEF{"message"}% | ||||||||||||||
| > > |
%TMPL:DEF{"titleaction"}% (test =titleaction=) %TMPL:END%
%TMPL:DEF{"webaction"}% test =webaction= %TMPL:END%
%TMPL:DEF{"heading"}%
Test heading %TMPL:END%
%TMPL:DEF{"message"}%
| ||||||||||||||
Test message. Blah blah blah blah blah blah blah blah blah blah blah...
| |||||||||||||||
| Changed: | |||||||||||||||
| < < |
| ||||||||||||||
| > > |
| ||||||||||||||
Test topicaction: | |||||||||||||||
| Changed: | |||||||||||||||
| < < | OK %.TMPL:P{"sep"}% Register %.TMPL:END% %.TMPL:INCLUDE{"oopsbase"}% | ||||||||||||||
| > > | [[%WEB%.%TOPIC%][OK]] %TMPL:P{"sep"}% [[%TWIKIWEB%.TWikiRegistration][Register]] %TMPL:END% %TMPL:INCLUDE{"oopsbase"}% | ||||||||||||||
|
twiki.tmpl, that all other templates include.
| Template variable: | Defines: |
|---|---|
| %TMPL:DEF{"sep"}% | "|" separator |
| %TMPL:DEF{"htmldoctype"}% | Start of all HTML pages |
| %TMPL:DEF{"standardheader"}% | Standard header (ex: view, index, seach) |
| %TMPL:DEF{"simpleheader"}% | Simple header with reduced links (ex: edit, attach, oops) |
| %TMPL:DEF{"standardfooter"}% | Footer, excluding revision and copyright parts |
| %TMPL:DEF{"oops"}% | Skeleton of oops dialog |
preview.tmpl templateoopspreview.tmpl template
%TMPL:INCLUDE{"twiki"}%
%TMPL:DEF{"titleaction"}% (oops) %TMPL:END%
%TMPL:DEF{"webaction"}% *Attention* %TMPL:END%
%TMPL:DEF{"heading"}% Topic is not saved yet %TMPL:END%
%TMPL:DEF{"message"}% Please go back in your browser and save the topic. %TMPL:END%
%TMPL:DEF{"topicaction"}%
%TMPL:END%
%TMPL:P{"oops"}%
.tmpl filename extension - it contains unresolved %VARIABLES%, but can still be previewed directly in a browser.
.tmpl filename extension - it contains unresolved %VARIABLES%, but can still be previewed directly in a browser.
| META FILEATTACHMENT | attr="h" comment="Example of oopstest.tmpl rendered" date="999598142" name="testscreen.gif" path="C:\02_TWikiDocs\testscreen.gif" size="9460" user="MikeMannix" version="1.1" |
|---|---|
| META TOPICMOVED | by="MikeMannix" date="1000277381" from="TWiki.TWikiTemplateSystem" to="TWiki.TWikiTemplates" |