Help:Wiki template: Difference between revisions

From COLLADA Public Wiki
Jump to navigation Jump to search
Elf (talk | contribs)
copying text I wrote from http://www.bayteam.org/wiki/Help:Templates
 
Elf (talk | contribs)
 
(15 intermediate revisions by the same user not shown)
Line 1: Line 1:
This wiki software allows us to define '''templates''', which in other languages might be called '''macros''' (or other similar terms).  
{{HelpTOC}}
This wiki software allows us to define '''templates''', which are the same concept as '''macros''' in some languages.  


==Overview==
==Overview==
Line 6: Line 7:
  This page needs more work to make it look good.
  This page needs more work to make it look good.


Furthermore, templates can have ''arguments'' (parameters) that allow you to specify repetitive data in a standard and more easily understandable way. For example, you could define a template named '''trial-committee''' that provides space for someone to type the names of trial committee members and then displays the list in a nice format as defined within the template, rather than making the editor do all the work over and over.
Furthermore, templates can have ''arguments'' (parameters) that allow you to specify repetitive data in a standard and more easily understandable way. For example, you could define a template named '''plug-in''' that provides space for someone to type the basic information about a COLLADA plug-in and then displays the info in a nice format as defined within the template, rather than making the editor do all the work over and over.


==Template usage==
==Template usage==
When editing an article,  you see templates like this:
When editing an article,  you include templates using double braces around the template's name, like this:
   <nowiki>{{needswork}}</nowiki>
   <nowiki>{{needswork}}</nowiki>
or like this:
or like this, if the template allows named arguments:
   <nowiki>{{trial-committee|chair=Fred Smith|secretary1=Jane Doe|secretary2=Tien Tranh}}</nowiki>
   <nowiki>{{plug-in | name = My Plug In | web = http://www.mycompany.com | version = 1.4}}</nowiki>


==Template definition==
==Template definition==
To create a template, you simply create an article titled "Template:nameofyourtemplate"; for example, Template:needswork or Template:trial-committee. Whatever  you put into that article then appears whenever you insert the template (as shown in "Template usage") into another article.
To create a template, just create an article titled "Template:nameofyourtemplate"; for example, Template:needswork or Template:plug-in. Whatever  you put into that article then appears whenever you insert the template (as shown in "Template usage") into another article.


==Complexities==
For example, perhaps you want the '''plug-in''' template shown above to display text like this:
Of course, it's almost never ''that'' simple. Here are some example templates, whose content you can examine by clicking their '''edit''' tabs:
----
*[[Template:Addtocategory]], which displays standard text and also uses a predefined variable to display the name of the current article.
*'''Plug-in name:''' My Plug In
*[[Template:Disambig]], which displays standard text and also puts any article in which it appears into a specific category.
*'''Web site:''' http://www.mycompany.com
*[[Template:Trial]], which allows parameters, then displays the values into a formatted table AND this template displays usage information about the template itself.
*'''Current released version:''' 1.4
----


==See also==
In this case, the template definition ([[Template:plug-in]]) looks similar to this:
*[[Special:Prefixindex]] where you can select the '''Template''' namespace and see the names of all templates that currently exist.
 
*[[BTwiki templates]], which lists existing templates and shows what they produce
<nowiki>*'''Plug-in name:''' {{{name}}}</nowiki>
<nowiki>*'''Web site:''' {{{web}}}</nowiki>
<nowiki>*'''Current released version:''' {{{version}}}</nowiki>
 
==Advanced features==
You can use special markup for:
*Things that appear only in the template definition page but not where the template occurs (<nowiki><noinclude>...</noinclude></nowiki>).
*Vice-versa (<nowiki><includeonly>...</includeonly></nowiki>).
 
The former is useful things such as displaying usage information about the template on the template's page; the latter is useful for things such as putting an article into a category when the template is used in the article into a [[category]], but not putting the template itself into the category.
 
See [[Template:Disambig]] for examples of this markup
 
===Optional arguments===
You can include optional arguments using the '''$if:''' parser function. For example:
<nowiki> {{ $if: {{{company|}}} | Company name is {{{company}}} | No company name supplied}} </nowiki>
which displays "Company name is foo" if a company argument is present, or "No company name supplied" if it isn't.
 
For more information: http://meta.wikimedia.org/wiki/ParserFunctions
 
===Additional features===
There are additional features that are useful in templates, including predefined variables that do such things as calculate the name of the current article. These are documented elsewhere; see "External links."
 
==Currently defined templates==
To see descriptions of defined templates and examples of usage (if someone has provided it):
*See [[Help:List of COLLADA wiki templates]]
 
To see just the names of all templates that currently exist in this wiki:
#Either:
#*Use the '''Special pages''' link in the left navigation bar and click '''Prefix index'''.
#*Go directly to the special "article" [[Special:Prefixindex]].
#Select the '''Template''' namespace and click '''Go'''.


==External links==
==External links==
(need links to detailed help on wikipedia, wikimedia, etc.)  
*[http://meta.wikimedia.org/wiki/Help:Template Wikimedia Help:Template article]
*[http://en.wikipedia.org/wiki/Wikipedia:Template_namespace Wikipedia Template namespace article]
*[http://meta.wikimedia.org/wiki/ParserFunctions Parser functions (conditional content in templates)]


[[Category:Help]]
[[Category:Help|Templates]][[Category:Templates]]

Latest revision as of 00:18, 5 March 2009

Help
Wiki

About (overview)
Search
FAQ
Help

Navigation

Portals
Categories
Searching

Editing

Basic editing
Article names
Adding article
Formatting
Linking
Tables
Redirects
Deleting
Copying
Images

Policies and guidelines

Standard article layout
Review edits, spam
Bugs

COLLADA

FAQ
Tutorials

This wiki software allows us to define templates, which are the same concept as macros in some languages.

Overview

A template can define standard text that you'd like to appear in more than one place. For example, you could define a template named needswork that, when inserted into a page, displays text like this:

This page needs more work to make it look good.

Furthermore, templates can have arguments (parameters) that allow you to specify repetitive data in a standard and more easily understandable way. For example, you could define a template named plug-in that provides space for someone to type the basic information about a COLLADA plug-in and then displays the info in a nice format as defined within the template, rather than making the editor do all the work over and over.

Template usage

When editing an article, you include templates using double braces around the template's name, like this:

 {{needswork}}

or like this, if the template allows named arguments:

  {{plug-in | name = My Plug In | web = http://www.mycompany.com | version = 1.4}}

Template definition

To create a template, just create an article titled "Template:nameofyourtemplate"; for example, Template:needswork or Template:plug-in. Whatever you put into that article then appears whenever you insert the template (as shown in "Template usage") into another article.

For example, perhaps you want the plug-in template shown above to display text like this:



In this case, the template definition (Template:plug-in) looks similar to this:

*'''Plug-in name:''' {{{name}}}
*'''Web site:''' {{{web}}}
*'''Current released version:''' {{{version}}}

Advanced features

You can use special markup for:

  • Things that appear only in the template definition page but not where the template occurs (<noinclude>...</noinclude>).
  • Vice-versa (<includeonly>...</includeonly>).

The former is useful things such as displaying usage information about the template on the template's page; the latter is useful for things such as putting an article into a category when the template is used in the article into a category, but not putting the template itself into the category.

See Template:Disambig for examples of this markup

Optional arguments

You can include optional arguments using the $if: parser function. For example:

 {{ $if: {{{company|}}} | Company name is {{{company}}} | No company name supplied}} 

which displays "Company name is foo" if a company argument is present, or "No company name supplied" if it isn't.

For more information: http://meta.wikimedia.org/wiki/ParserFunctions

Additional features

There are additional features that are useful in templates, including predefined variables that do such things as calculate the name of the current article. These are documented elsewhere; see "External links."

Currently defined templates

To see descriptions of defined templates and examples of usage (if someone has provided it):

To see just the names of all templates that currently exist in this wiki:

  1. Either:
    • Use the Special pages link in the left navigation bar and click Prefix index.
    • Go directly to the special "article" Special:Prefixindex.
  2. Select the Template namespace and click Go.

External links