Community Central
Community Central
(The "/doc" subpage system)
(help page cleanup)
Line 1: Line 1:
  +
#REDIRECT [[Help:Contents]]
{{Tocright}}A '''template''' is a piece of text (including tables, pictures, and code) that can be included into other pages. This allows that text to be edited in one place and then updated on many pages at once.
 
 
A template is any page in the template [[Help:namespace|namespace]], which means any page beginning with "Template:", such as Template:Templatename.
 
 
For basic information on how templates work, see [[Help:Templates]].
 
 
==How do I create a template?==
 
Create a page in the Template namespace, by creating it with the title "Template:Your_template_name". The template name ''can'' include spaces and symbols, but you will want the name to be easy to remember and easy to type, so the shorter and simpler the better.
 
 
==How do I use parameters in a template?==
 
:''Main article: [[Help:Template parameters]]''
 
 
Templates allow you to pass parameters that can be used to affect the content or design of the template.
 
 
For example:
 
 
<code><nowiki>{{box|text}}</nowiki></code>
 
 
...might produce a box containing <code>text</code>.
 
 
Alternatively:
 
 
<code><nowiki>{{box|bgcolor=yellow|textcolor=blue|caption=A yellow house}}</nowiki></code>
 
 
...might produce a box with a yellow background and blue text, with a caption describing it as such.
 
 
==How do I use parser functions in a template?==
 
:''Main article: [[Help:Parser functions]]''
 
 
Parser functions allow you to use a little bit of programming logic in your templates, including "if" statements and basic calculations. For instance, you can hide table rows which contain empty parameters by using:
 
 
<pre><nowiki>{{#if: {{{input|}}} | {{!}}-
 
{{!}} {{{input}}} }}</nowiki></pre>
 
 
Produces the following code only if input is defined.
 
 
<pre>
 
|-
 
| input
 
</pre>
 
 
<code><nowiki>{{!}}</nowiki></code> is used in the above parser function instead of | as the extension uses | to separate parameters. <code><nowiki>{{!}}</nowiki></code> is a template at [[Template:!]] which transcludes | into the code after the parser function has been validated.
 
 
==The "/doc" subpage system==
 
In the early years of Wikipedia and Wikia, template documentation (if any) was either on the talk page or (in "noinclude" tags) on the template page itself. For various reasons, including problems of template protection, both organizations have moved to standardize documentation on separate "/doc" subpages. Wikia virtually completed the process in late 2008. All Wikia sites created earlier were given few or no such "/doc" pages. Contributors to such sites are urged to create separate documentation subpages following the new standard, wherever convenient. See [[w:c:starter|the Starter Wikia]] for pages that can be freely copied as part of the process. That wiki adds new pages from time to time and is therefore worth checking at intervals.
 
 
==See also==
 
* [[m:Help:Parser function|General info about parser function on Meta-Wiki]]
 
* [[m:Help:ParserFunctions|Information about the ParserFunctions extension on Meta-Wiki]]
 
 
[[Category:Help|Creating templates]]
 
[[Category:Templates help|Creating templates]]
 
[[Category:Expand|Creating templates]]
 
 
[[de:Hilfe:Vorlagen erstellen]]
 

Revision as of 17:44, 30 September 2010

Redirect to: