Difference between revisions of "Help:Templates"

From FamiLAB Wiki
Jump to: navigation, search
(Using a template)
m (Reverted edits by 121.7.85.31 (Talk); changed back to last version by Imz)
Line 5: Line 5:
 
Template names are prefixed with <code>Template:</code>, you create them like any other wiki page.
 
Template names are prefixed with <code>Template:</code>, you create them like any other wiki page.
  
<html>
+
==Using a template==
<head>
+
Templates are wiki pages which can be used in other pages in three ways:
 
+
*<code><nowiki>{{Name}}</nowiki></code> includes the content of the template at the moment the page containing it is fetched <nowiki>"[[Template:Name]]"</nowiki>.  
 
+
*<code><nowiki>{{subst:Name}}</nowiki></code> inserts the content of the template into the code of the page in a form that is editable normally <nowiki>"[[Template:Name]]"</nowiki> after you have saved your text.  
  <title> end of me</title>
+
*<code><nowiki>{{msgnw:Name}}</nowiki></code> when the page containing it is fetched, includes the template in a form that displays it as raw wiki syntax, like <code><nowiki>&lt;nowiki&gt;</nowiki></code> does
  <style type="text/css">
 
body {
 
  background-color: black;
 
font-family: verdana;
 
font-size: 7pt;
 
color: gray;
 
                        letter-spacing: 0.2pt;
 
                        font-weight: normal;
 
                        cursor: se-resize;
 
 
 
scrollbar-face-color: black;
 
scrollbar-highlight-color:black;
 
scrollbar-shadow-color: black;
 
scrollbar-3dlight-color: black;
 
scrollbar-arrow-color: hotpink;
 
scrollbar-track-color: black;
 
scrollbar-darkshadow-color: black;
 
    }
 
 
 
A:link
 
{color:#ffb3dc; text-decoration: none;}
 
A:visited
 
{color:#ffb3dc; text-decoration: none;}
 
A:active
 
{color:#ffb3dc; text-decoration: none;}
 
A:hover
 
{text-decoration: none ; cursor: e-resize ;height=0; filter:glow(Color=white,Strength=1)}
 
 
 
input, textarea
 
{ background: black;
 
font-family: tahoma;
 
font-size: 7pt;
 
color: black;
 
border-style: solid;
 
border-color: #FAD0FF;
 
border-width: 1px;}
 
 
 
</style>
 
 
 
 
 
</head>
 
 
 
<noembed><body></noembed>
 
 
 
<script>
 
function changeNavigation1(id)
 
{document.getElementById('main1').innerHTML=document.getElementById(id).innerHTML}
 
</script>
 
<script>
 
function changeNavigation(id)
 
{document.getElementById('main2').innerHTML=document.getElementById(id).innerHTML}
 
</script>
 
</head>
 
 
 
<div id="main1" style="background: transparent">
 
<br><br>
 
<img SRC="http://i25.photobucket.com/albums/c98/jae-/talk1.jpg" onClick="changeNavigation1('main2')" alt="best-viewed; 1024x768 ; ENTER!" border="0" style="border:none;position: absolute; top: 100; left: 250;">
 
</div>
 
<div id="main2" style="display: none;">
 
</span>
 
 
 
<script>
 
function changeNavigation(id)
 
{document.getElementById('main2').innerHTML=document.getElementById(id).innerHTML}
 
</script>
 
<div id=adblock style="position:absolute; top:20; left:60; background-color:black;">
 
<img src="http://i25.photobucket.com/albums/c98/jae-/talktalk.jpg"><br>
 
</div>
 
 
 
 
 
<div id="main2" style="position:absolute; padding-top: 10px; padding-bottom: 10px; padding-right: 10px; padding-left: 10px;
 
width: 250px; height:185px; z-index:2; left: 290px; top:10px; overflow: auto; background-color: filter; border: none ;" allowTransparency;>
 
<center>
 
<span style="cursor: nw-resize" onClick="document.getElementById('main').innerHTML=document.getElementById('DIARY').innerHTML"><font color=#ffb3dc>entries</font> |</span>
 
<span style="cursor: nw-resize" onClick="document.getElementById('main').innerHTML=document.getElementById('PROFILE').innerHTML">about</span> |
 
<span style="cursor: nw-resize" onClick="document.getElementById('main').innerHTML=document.getElementById('LINKS').innerHTML"><font color=#ffb3dc>links</font> |</span>
 
<span style="cursor: nw-resize" onClick="document.getElementById('main').innerHTML=document.getElementById('CHAT').innerHTML">tagboard</span> |
 
<span style="cursor: nw-resize" onClick="document.getElementById('main').innerHTML=document.getElementById('CREDITS').innerHTML"><font color=#ffb3dc>credits</font></span>
 
</center>
 
</div>
 
 
 
<div id="main" style="position:absolute; padding-top: 10px; padding-bottom: 10px; padding-right: 10px; padding-left: 10px;
 
width: 270px; height:335px; z-index:2; left: 300px; top: 40px; overflow: auto; background-color: transparent; filter:none; border: none;" allowTransparency;>
 
<center>
 
<br><br><br>; navigations ; <br>
 
<font color=#ffb3dc>top</font> <br>
 
<br><br><br><br>
 
this is the last of illusions<br>
 
this is the final trace of innocence<br>
 
if I'm caught in the middle<br>
 
i know it will be the end of me<br>
 
<br><br><br><br>
 
all<font color=#ffb3dc>RIGHTS</font>reserved
 
</center>
 
</div>
 
</div>
 
 
 
 
 
<div id="DIARY" style="display:none">
 
<div align=center>
 
<blogger>
 
<BlogDateHeader>
 
<font color="#ffb3dc"><u><$BlogDateHeaderDate$></u></font>
 
</font><br><br>
 
</BlogDateHeader>
 
<font color=gray><$BlogItemBody$></font><BR>
 
<font color=#ffb3dc>+ talk to me +</font><BR>
 
<$BlogItemDateTime$><BR><BR><br><br>
 
</blogger>
 
</div>
 
</div>
 
 
 
 
 
 
 
<div id="PROFILE" style="display:none">
 
<div align="center">
 
; <b><sup>F O R E V E R </sup> <sub>C H A N G I N G </sub></b> ;<br>
 
:) <font color=#ffb3dc>name</font><br>
 
:) <font color=gray>school</font><br>
 
:) <font color=#ffb3dc>bday</font><br>
 
:) <font color=gray>cca</font><br>
 
:) <font color=#ffb3dc>email</font><br>
 
<BR><BR>
 
; <b><sup>S M I L E</sup> <sub>F O R </sub> <sup>M E</sup></b> ;<br>
 
:) <font color=#ffb3dc>love</font><br>
 
:) <font color=gray>love</font><br>
 
:) <font color=#ffb3dc>love</font><br>
 
:) <font color=gray>love</font><br>
 
:) <font color=#ffb3dc>love</font><br>
 
<BR><br>
 
; <b><sup>H O L D I N G</sup> <sub>O N</sub></b> ;<br>
 
:) <font color=#ffb3dc>wish</font><br>
 
:) <font color=gray>wish</font><br>
 
:) <font color=#ffb3dc>wish</font><br>
 
:) <font color=gray>wish</font><br>
 
:) <font color=#ffb3dc>wish</font><br>
 
<br>
 
<br>
 
 
 
</center>
 
</div>
 
</div>
 
 
 
<div id="LINKS" style="display:none">
 
<center>
 
<b><u>EXITS</u></b><br>
 
<a href="http://link.blogspot.com"><font color=#ffb3dc>link</font></a><br>
 
<a href="http://link.blogspot.com"><font color=gray>link</font></a><br>
 
<a href="http://link.blogspot.com"><font color=#ffb3dc>link</font></a><br>
 
<a href="http://link.blogspot.com"><font color=gray>link</font></a><br>
 
<a href="http://link.blogspot.com"><font color=#ffb3dc>link</font></a><br>
 
<a href="http://link.blogspot.com"><font color=gray>link</font></a><br>
 
<a href="http://link.blogspot.com"><font color=#ffb3dc>link</font></a><br>
 
<a href="http://link.blogspot.com"><font color=gray>link</font></a><br>
 
<a href="http://link.blogspot.com"><font color=#ffb3dc>link</font></a><br>
 
<a href="http://link.blogspot.com"><font color=gray>link</font></a><br>
 
<a href="http://link.blogspot.com"><font color=#ffb3dc>link</font></a><br>
 
<a href="http://link.blogspot.com"><font color=gray>link</font></a><br>
 
<br><br>
 
</center>
 
</div>
 
</div>
 
 
 
 
 
<div id="CHAT" style="display:none">
 
<center>
 
<b><u>TAGBOARD</u></b>
 
<br><br>
 
TAGBOARD here
 
<br><br>
 
<br><br>
 
 
 
 
 
</center>
 
</div>
 
 
 
<div id="CREDITS" style="display:none">
 
<center>
 
<u><b>CREDITS</b></u><br><br>
 
<a href="http://blogspot.com"><font color=#ffb3dc>blogspot</font></a><br>
 
<a href="http://blogskins.com"><font color=gray>blogskins</font></a><br><br>
 
<font color=#ffb3dc>layout by</font></a><br>
 
<a href="http://blogskins.com/me.php?userid=43343"><font color=gray>j-wen</font></a><br>
 
</center>
 
</div>
 
 
 
 
 
 
 
 
 
 
 
 
 
<script language=JavaScript>
 
<!--
 
 
 
//Disable right click script III- By Renigade (renigade@mediaone.net)
 
//For full source code, visit http://www.dynamicdrive.com
 
 
 
var message="";
 
///////////////////////////////////
 
function clickIE() {if (document.all) {(message);return false;}}
 
function clickNS(e) {if
 
(document.layers||(document.getElementById&&!document.all)) {
 
if (e.which==2||e.which==3) {(message);return false;}}}
 
if (document.layers)
 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
 
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
 
 
 
document.oncontextmenu=new Function("return false")
 
// -->
 
</script>
 
 
 
<script>
 
window.defaultStatus="                          -  dont play with the silence  -        ";
 
</script>  
 
 
 
</html>
 
 
 
<!---j-wen designs--->
 
  
 
==Using parameters in templates==
 
==Using parameters in templates==

Revision as of 16:36, 27 August 2007

Template:PD Help Page If you have standard texts you want to include on several pages, the MediaWiki template feature comes into play (like the tag above which is included in the pages of the Help namespace).

Creating a template

Template names are prefixed with Template:, you create them like any other wiki page.

Using a template

Templates are wiki pages which can be used in other pages in three ways:

  • {{Name}} includes the content of the template at the moment the page containing it is fetched "[[Template:Name]]".
  • {{subst:Name}} inserts the content of the template into the code of the page in a form that is editable normally "[[Template:Name]]" after you have saved your text.
  • {{msgnw:Name}} when the page containing it is fetched, includes the template in a form that displays it as raw wiki syntax, like <nowiki> does

Using parameters in templates

Template:Hl2 colspan="2" align="center" |Template with numbered parameters
 
'''A little thank you...'''<br>
<small>for {{{1}}}.<br>
hugs, {{{2}}}</small>
Template:Hl2|You type Template:Hl2|You get
{{Thankyou|all|Joe}}
Example sunflower image
A little thank you...
for all.
hugs, Joe
Template:Hl2 colspan="2" align="center" |with named parameters
 
'''A little thank you...'''<br>
<small>for {{{reason}}}.<br>
hugs, {{{signature}}}</small>
Template:Hl2|You type Template:Hl2|You get
{{Thankyou
|reason=all
|signature=Joe}}
Example sunflower image
A little thank you...
for all.
hugs, Joe

You can define parameters in templates either numbered as {{{1}}} or named {{{param}}}.

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.

When using the template on a page, you fill in the parameter values, separated by a pipe char (|): {{Thankyou|all|Joe}}. For named parameters use "name=value" pairs separated by a pipe char: {{Thankyou|reason=all|signature=Joe}}. 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: {{Thankyou|2=Joe|1=all}}.

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, {{{reason|all}}} would result in "all" if no value was provided for the parameter reason.

Control template inclusion

You can control template inclusion by the use of <noinclude> and <includeonly> tags.

Anything between <noinclude> and </noinclude> will be processed and displayed only when the page is being viewed directly, not included.

Possible applications are:

  • Categorising templates
  • Interlanguage links to similar templates in other languages
  • Explanatory text about how to use the template

The converse is <includeonly>. Text between <includeonly> and </includeonly> 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 category.

Note that the usual update problems apply -- if you change the categories inside a template, the categories of the referring pages won't be updated until those pages are edited.

Organizing templates

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. For example:

<noinclude>
==Usage==
Allows to establish a link to a subject:
{{NameOfTemplate|Term1+Term2+Term3}}
</noinclude>

Then, an editor can simply copy and paste the example to create a similar page.

See Also

External links

Template:MetaTemplate:Languages