https://wikis.swarthmore.edu/telescope/index.php?title=Help:Templates&feed=atom&action=historyHelp:Templates - Revision history2024-03-29T13:47:02ZRevision history for this page on the wikiMediaWiki 1.26.4https://wikis.swarthmore.edu/telescope/index.php?title=Help:Templates&diff=98&oldid=prevTeleAdmin: 1 revision2009-05-22T13:45:16Z<p>1 revision</p>
<table class='diff diff-contentalign-left'>
<tr style='vertical-align: top;' lang='en'>
<td colspan='1' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='1' style="background-color: white; color:black; text-align: center;">Revision as of 13:45, 22 May 2009</td>
</tr><tr><td colspan='2' style='text-align: center;' lang='en'><div class="mw-diff-empty">(No difference)</div>
</td></tr></table>TeleAdminhttps://wikis.swarthmore.edu/telescope/index.php?title=Help:Templates&diff=97&oldid=prevDocu: /* See also */ +Help:Parser functions in templates2009-03-11T02:10:16Z<p><span dir="auto"><span class="autocomment">See also: </span> +<a href="/telescope/index.php?title=Help:Parser_functions_in_templates&action=edit&redlink=1" class="new" title="Help:Parser functions in templates (page does not exist)">Help:Parser functions in templates</a></span></p>
<p><b>New page</b></p><div>{{PD Help Page}}<br />
If you have standard texts you want to include on several pages, the MediaWiki template feature comes into play.<br />
<br />
==Creation==<br />
Templates are standard wiki pages whose content is designed to be [http://en.wikipedia.org/w/index.php?title=Transclusion transcluded] (embedded) inside other pages. Templates follow a convention that the name is prefixed with codeTemplate:/code, assigning it to that namespace. Therefore you can [[Help:Starting a new page|create them like any other wiki page]].<br />
<br />
==Usage==<br />
Templates are wiki pages which can be used in other pages in three ways:<br />
<br />
*codenowiki{{Name}}/nowiki/code 'transcludes' (i.e. includes a copy of) the content of the template (stored in the page nowiki[[Template:Name]]/nowiki) whenever the page containing the template transclusion is fetched and displayed; i.e. if the template is later changed, the displayed transcluding page will automatically change too<br />
*codenowiki{{subst:Name}}/nowiki/code replaces that string with the contents of the template, in the source of the transcluding page, when you save that page; the copy of the template contents can then be edited normally (and separately from the original in the template page). '''''Note''''': don't use this if you are looking to continually propagate changes from the source template to the page(s) that references it.<br />
*codenowiki{{msgnw:Name}}/nowiki/code includes the template in a form that displays it as raw wiki syntax (the way codenowikilt;nowikigt;/nowiki/code does) when the page containing it is fetched<br />
<br />
In fact, an ordinary wiki page can also be used as a template, simply by specifying the namespace it resides in, so:<br />
<br />
*codenowiki{{Template:Pagename}}/nowiki/code includes codenowiki[[Template:Pagename]]/nowiki/code<br />
*codenowiki{{Foo:Pagename}}/nowiki/code includes codenowiki[[Foo:Pagename]]/nowiki/code<br />
*codenowiki{{:Pagename}}/nowiki/code includes codenowiki[[Pagename]]/nowiki/code<br />
<br />
If no such namespace exists, the full title is assumed to be a template:<br />
<br />
*codenowiki{{Foo:Bar}}/nowiki/code includes codenowiki[[Template:Foo:Bar]]/nowiki/code<br />
<br />
===Parameters===<br />
div style=float:right; margin:8px;<br />
{| {{Prettytable}} <br />
|-<br />
|{{Hl2}} colspan=2 align=center |'''Template with numbered parameters''' <br />
|-<br />
| colspan=2 |<br />
prenowiki <br />
'''A little thank you...'''br /<br />
smallfor {{{1}}}.br /<br />
hugs, {{{2}}}/small<br />
/nowiki/pre <br />
|-<br />
|{{Hl2}}|'''You type''' <br />
|{{Hl2}}|'''You get'''<br />
|-<br />
|codenowiki{{Thankyou|all your hard work|Joe}}/nowiki/code<br />
|<br />
{{Thankyou|all your hard work|Joe}}<br />
|-<br />
|{{Hl2}} colspan=2 align=center |'''with named parameters''' <br />
|-<br />
| colspan=2 |<br />
prenowiki <br />
'''A little thank you...'''br /<br />
smallfor {{{reason}}}.br /<br />
hugs, {{{signature}}}/small<br />
/nowiki/pre <br />
|-<br />
|{{Hl2}}|'''You type''' <br />
|{{Hl2}}|'''You get'''<br />
|-<br />
|prenowiki{{Thankyou<br />
|reason=all your hard work<br />
|signature=Joe}}/nowiki/pre<br />
|<br />
{{Thankyou|all your hard work|Joe}}<br />
|}<br />
/div<br />
You can define parameters in templates either numbered as codenowiki{{{1}}}/nowiki/code or named codenowiki{{{param}}}/nowiki/code. <br />
<br />
'''Example:''' You want a little thank you note you can put on the talk page of other users. It will contain a reason and your signature. You could create [[Template:Thankyou]] to enter your text, as in the example in the table.<br />
<br />
When using the template on a page, you fill in the parameter values, separated by a pipe char (|): codenowiki{{Thankyou|all your hard work|Joe}}/nowiki/code. For named parameters use name=value pairs separated by a pipe char: codenowiki{{Thankyou|reason=all your hard work|signature=Joe}}/nowiki/code. The advantage of using named parameters in your template is that they are flexible in order. It also makes the template easier to understand if you have many parameters. If you want to change the order of numbered parameters, you have to mention them explicitly: codenowiki{{Thankyou|2=Joe|1=all your hard work}}/nowiki/code.<br />
<br />
You can also provide default values for parameters, i.e. values that are going to be used if no value is provided for a parameter. For example, codenowiki{{{reason|all your hard work}}}/nowiki/code would result in ''all your hard work'' if no value was provided for the parameter ttreason/tt.<br />
<br />
===Control template inclusion===<br />
You can control template inclusion by the use of codenowikinoinclude/nowiki/code and<br />
codenowikiincludeonly/nowiki/code tags.<br />
<br />
Anything between codenowikinoinclude/nowiki/code and codenowiki/noinclude/nowiki/code will be processed and<br />
displayed only when the template's page is being viewed directly.<br />
<br />
Possible applications are:<br />
* Categorising templates<br />
* Interlanguage links to similar templates in other languages<br />
* Explanatory text about how to use the template<br />
<br />
The converse is codenowikiincludeonly/nowiki/code. Text between codenowikiincludeonly/nowiki/code and codenowiki/includeonly/nowiki/code will be processed and displayed only when the page is being included. The obvious application is to add all pages containing a given template to a [[Help:Categories|category]], without putting the template itself into that category.<br />
<br />
'''Note:''' when you change the categories applied by a template, the categorization of the pages that use that template may not be updated until some time later: this is handled by the {{mediawiki|Manual:Job queue|job queue}}.<br />
<br />
===Organizing templates===<br />
For templates to be effective users need to find them and be able to use them. A simple technique is to include an example on the template page.<br />
For example:<br />
div style=display:table; width:auto;pre<br />
noinclude<br />
== Usage ==<br />
Allows to establish a link to a subject:<br />
nowiki{{NameOfTemplate|Term1+Term2+Term3}}/nowiki<br />
/noinclude<br />
/pre/div<br />
<br />
Then, an editor can simply copy and paste the example to create a similar page.<br />
<br />
==Copying from one wiki to another==<br />
Templates often require [http://meta.wikimedia.org/wiki/Help:CSS CSS] or other templates, so users frequently have trouble copying templates from one wiki to another. The steps below should work for most templates:<br />
# Copy the template text to the new wiki, either by [http://meta.wikimedia.org/wiki/Help:Import importing] or with a link in the edit summary to the original page (for attribution).<br />
# Look for CSS classes (like class=foobar) in the template text. If those classes appear in MediaWiki:Common.css or MediaWiki:Monobook.css on the original wiki, copy them to MediaWiki:Common.css on the new wiki.<br />
# Look for templates (like nowiki{{foobar}}/nowiki) inside the template text, and copy those templates to the new wiki.<br />
# If the template uses [[Help:Extension:ParserFunctions|ParserFunctions]], you must install the {{mediawiki|Extension:ParserFunctions|ParserFunctions extension}}.<br />
<br />
==See also==<br />
*[[Help:External searches]] – a template special use case example<br />
*[[Help:Magic words]] – fancy stuff you may find in some templates<br />
*[[Help:Parser functions in templates]]<br />
*{{meta|Help:Template}}<br />
*{{meta|Help:Embed page}} – embedding pages from [[Help:namespaces|namespaces]] other than codeTemplate:/code.<br />
<br />
[[Category:Help|{{PAGENAME}}]]<br />
[[Category:Template]]<br />
{{Languages|Help:Templates}}</div>Docu