Difference between revisions of "Help:Template"

m (How to Create a Template: more)
m (-> lvl 2 headers, rm lines)
Line 1: Line 1:
 
A '''template''' is a page anyone can create.  An example template is [[Template:Stub]].  If someone creates an article that belongs in a certain category, they can add the template name for that category by adding the template name in double brackets at the bottom of the page, like so: {{category name}}.  For example, this page has the the template <nowiki>{{Tutorial}}</nowiki> at the bottom of the page.
 
A '''template''' is a page anyone can create.  An example template is [[Template:Stub]].  If someone creates an article that belongs in a certain category, they can add the template name for that category by adding the template name in double brackets at the bottom of the page, like so: {{category name}}.  For example, this page has the the template <nowiki>{{Tutorial}}</nowiki> at the bottom of the page.
  
----
+
== List of Templates ==
 
 
=== List of Templates ===
 
 
:''All templates can be found [http://www.artofproblemsolving.com/Wiki/index.php?title=Special%3APrefixindex&from=&namespace=10 here].''
 
:''All templates can be found [http://www.artofproblemsolving.com/Wiki/index.php?title=Special%3APrefixindex&from=&namespace=10 here].''
[[Template:Stub]]
 
  
[[Template:Tutorial]]
+
== How to Create a Template ==
 
 
[[Template:Image needed]]
 
 
 
[[Template:Problems]]
 
 
 
[[Template:AoPSMember]]
 
 
 
[[Template:Alternate solutions]]
 
----
 
 
 
=== How to Create a Template ===
 
  
 
To create a template, which we will call "Sample" for the purposes of this tutorial, first navigate to the page Template:Sample.  Edit the page, then add the following text (anything in bold can be changed):
 
To create a template, which we will call "Sample" for the purposes of this tutorial, first navigate to the page Template:Sample.  Edit the page, then add the following text (anything in bold can be changed):
 
----
 
  
 
<code>'''''This article is a sample.  It's purpose is to do this and that and this that.'''''
 
<code>'''''This article is a sample.  It's purpose is to do this and that and this that.'''''
Line 30: Line 14:
 
<nowiki>[[Category:</nowiki>'''Samples'''<nowiki>]]</nowiki>
 
<nowiki>[[Category:</nowiki>'''Samples'''<nowiki>]]</nowiki>
 
</code>
 
</code>
 
----
 
  
 
Now, whenever you add the code <nowiki>{{sample}}</nowiki> at the end of an article, it will display the text "''This article is a sample.  It's purpose is to do this and that and this that.''
 
Now, whenever you add the code <nowiki>{{sample}}</nowiki> at the end of an article, it will display the text "''This article is a sample.  It's purpose is to do this and that and this that.''
Line 44: Line 26:
  
 
For more information about parameters, view the [http://en.wikipedia.org/wiki/Help:Template Wikipedia page on templates] (note that Parser Functions are disabled).
 
For more information about parameters, view the [http://en.wikipedia.org/wiki/Help:Template Wikipedia page on templates] (note that Parser Functions are disabled).
 
----
 
  
 
[[Category:AoPSWiki]]
 
[[Category:AoPSWiki]]
 
{{Tutorial}}
 
{{Tutorial}}

Revision as of 15:18, 3 March 2007

A template is a page anyone can create. An example template is Template:Stub. If someone creates an article that belongs in a certain category, they can add the template name for that category by adding the template name in double brackets at the bottom of the page, like so: Template:Category name. For example, this page has the the template {{Tutorial}} at the bottom of the page.

List of Templates

All templates can be found here.

How to Create a Template

To create a template, which we will call "Sample" for the purposes of this tutorial, first navigate to the page Template:Sample. Edit the page, then add the following text (anything in bold can be changed):

This article is a sample. It's purpose is to do this and that and this that.

<noinclude>''This template will categorize articles that include it into [[:Category:Samples]].''</noinclude>

[[Category:Samples]]

Now, whenever you add the code {{sample}} at the end of an article, it will display the text "This article is a sample. It's purpose is to do this and that and this that. Also, the page Category:Samples will be automatically created. Any pages tagged with {{sample}} will automatically be added to Category:Samples.

Parameters

A template can hold parameters. On the template page, add {{{1}}} to create a parameter. When transcluding the template, use the format:

{{TemplateName| PARAMETER GOES HERE }}

Similarly, names can be used in the parameters. To create a parameter with a year, use {{{year}}}. For example, Template:Succession box uses:

{{Succesion box|before=1|title=The Number 2|after=3}}

For more information about parameters, view the Wikipedia page on templates (note that Parser Functions are disabled). This article is a tutorial about the AoPSWiki or AoPS Forum.