Difference between revisions of "Help:Template"

(Nicolas cleans OC)
(Reverted 1 edit by nicolascleansoc (Talk); changed back to last version by JDCohen)
Line 6: Line 6:
 
=Using Templates=
 
=Using Templates=
 
==Passing Parameters==
 
==Passing Parameters==
===Nicolas Cleans OC===
+
===Named Parameters===
 +
Named parameters are parameters which have a name to them. For example, the <code style="font-size: 10pt">{{TemplateEditLink|DomainPage}}</code> template uses named parameters. To use the DomainPage template, you would use code such as the following:
  
 +
<pre style="font-size: 10pt">
 +
{{ Domain_Page |
 +
reviews = <reviews></reviews> |
 +
vote = <vote></vote> |
 +
thumbnail = <thumbnail>AboutUs.org</thumbnail> |
 +
map = <map section="Address"></map>
 +
}}
 +
</pre>
  
Home
+
'''Do not be confused''' in this example - the tags being passed, such as <code style="font-size: 10pt"><nowiki><reviews></reviews></nowiki></code>, are '''not''' necessary to pass named parameters. '''The tags themselves are being passed to the template.'''
About Us
 
Promotions
 
About Our Services
 
Contact Us
 
About Nicolas Cleans OC!
 
We are a licensed and insured cleaning services provider.
 
  
We currently provide full-service cleaning for commercial businesses and residential dwellings in the following counties and cities:
+
In this example, <code style="font-size: 10pt">reviews</code>, <code style="font-size: 10pt">vote</code>, <code style="font-size: 10pt">thumbnail</code>, and <code style="font-size: 10pt">map</code> are all named parameters, because you must specify their name. Named parameters need to have an equal sign ( <code style="font-size: 10pt">=</code> ) between the name of the parameter and the value.
  
+ Orange County: Aliso Viejo, Ladera Ranch, Laguna Beach, Laguna Hills, Laguna Niguel, Mission Viejo, Newport Beach, San Clemente
+
Notice how there is a pipe ( <code style="font-size: 10pt">|</code> ) at the end of each line. This separates the previous parameter from the next. Now you are probably thinking, "then why do we need a pipe if we need to place the parameters on separate lines?" The thing is, you don't have to put them on separate lines. You can if you want. This template could be condensed into one line: <div style="float: right">And there it goes.......... --></div>
  
+ Riverside County:
+
<pre style="font-size: 10pt">
 
+
{{ Domain_Page|reviews = <reviews></reviews>|vote = <vote></vote>|thumbnail = <thumbnail>AboutUs.org</thumbnail>|map = <map section="Address"></map>}}
+ San Bernardino County:
+
</pre>
 
 
Ask us about our 24-Hour cleaning services. We're available for around-the-clock service!!!
 
 
 
 
 
--------------------------------------------------------------------------------
 
 
 
Do you have a question about our cleaning services? Please contact us by e-mail for more information. Or, call 949-573-1117 for a FREE CONSULTATION.
 
OUR CUSTOMERS SAY:
 
"Fantastic service...always courteous...we recommend this company to anyone."Jane W. (Mission Viejo, CA)
 
 
 
 
 
 
 
OUR GUARANTEE:
 
With the stress and pressures everyone endures on a daily basis (long work hours, social commitments, family), we understand that cleanliness and organization is an important factor for maintaining quality of life.
 
 
 
Therefore, we will stand by our guarantee and honor our original quote provided upon initial consultation, no matter the condition of the area(a) we are expected to clean and maintain.
 
 
 
Please contact us by e-mail or call 949-573-1117 for more information about our guarantee and related policies
 
 
 
Company Address
 
 
 
34111 La Serena Drive
 
Dana Point, CA 92629
 
 
 
www.nicolascleansoc.com
 
  
 
===Sequential Parameters===
 
===Sequential Parameters===

Revision as of 18:41, 14 November 2008

A template is a wiki page whose contents are specially intended to be inserted into another wiki page by the "transclusion" process. When you use a template, the template name is surrounded in double curly braces: {{NameOfTemplate}}.

If you're interested in using templates, just keep reading. If you're interesting in creating them, see the Creating Templates section of this page.

Using Templates

Passing Parameters

Named Parameters

Named parameters are parameters which have a name to them. For example, the {{DomainPage}} template uses named parameters. To use the DomainPage template, you would use code such as the following:

{{ Domain_Page |
 reviews = <reviews></reviews> |
 vote = <vote></vote> |
 thumbnail = <thumbnail>AboutUs.org</thumbnail> |
 map = <map section="Address"></map>
}}

Do not be confused in this example - the tags being passed, such as <reviews></reviews>, are not necessary to pass named parameters. The tags themselves are being passed to the template.

In this example, reviews, vote, thumbnail, and map are all named parameters, because you must specify their name. Named parameters need to have an equal sign ( = ) between the name of the parameter and the value.

Notice how there is a pipe ( | ) at the end of each line. This separates the previous parameter from the next. Now you are probably thinking, "then why do we need a pipe if we need to place the parameters on separate lines?" The thing is, you don't have to put them on separate lines. You can if you want. This template could be condensed into one line:
And there it goes.......... -->
{{ Domain_Page|reviews = <reviews></reviews>|vote = <vote></vote>|thumbnail = <thumbnail>AboutUs.org</thumbnail>|map = <map section="Address"></map>}}

Sequential Parameters

Sequential parameters do not have a name to them. It all matters in what order you pass them. For example, the {{color}} template engages sequential parameters. To use this template you would use:

{{color|Black|Blah blah blah blah blah.}}

Because this template is using sequential parameters, switching the two around (Black) would not give the desired output.

But then, how would you skip a parameter? Very simple. Simply leave a blank value. For example, Blah blah blah blah blah. (notice that the color parameter is skipped).

Of course, sequential parameters, like named parameters, must be separated by a pipe. And just like named parameters, you could place the parameters on separate lines.

Creating Templates

Before you create your template, make sure the template doesn't already exist by going to Special:Prefixindex and selecting Template from the namespace drop-down box.

When you are ready to create your template, go to http://www.aboutus.org/Template:NameOfNewTemplate (replacing NameOfNewTemplate with whatever you wish to call it). Make sure that the name of the template is not too long, but is descriptive enough of its function, and the name is easy enough to remember.

Your template can be simple, like {{smiley}}, or as complex as {{CategoryTOC}}.

MagicWords

MagicWords can be considered a predefined template without parameters.

This is a list of MagicWords that can be used in the wikitext. The way they are rendered vary with time (directly depending on time, or e.g. for number of articles, depending on the creation of other articles), on the project (it changes when the wikitext is copied), or on the page in which it occurs (it changes when the wikitext is copied, when the page is renamed, and when the page is included in another page).

List of Words

Receiving Passed Parameters

Named Parameters

Receiving passed parameters to a template is very easy. All you have to do is surround the name of the parameter in triple quotes where you want it in the template. For example, a template which would show the contents of the text parameter would be coded like this:

{{{text}}}

Sequential Parameters

Sequential parameters are quite the same thing, only you would use the number of the parameter, which starts at 1:

{{{1}}}

You can put the parameters in any order you want, for example:

{{{1}}} is a {{{2}}}. {{{1}}} likes {{{3}}}.

Default Values

If you want to have a default value for the parameter, which is shown if the template is embedded without specifying the parameter, you can add a pipe ( | ) to the end of the name of the parameter, followed by the default value. For example,

{{{text|Default Value}}}

Important Notes

When a parameter is not passed, and there is no default value, the parameter will be read as text. That means that {{{x}}}, replacing x with the name of the parameter being used will be seen in the place it is used.

List of MagicWords

Constants

{{SITENAME}} AboutUs
{{SERVER}} //aboutus.com
{{SERVERNAME}} aboutus.com
{{CONTENTLANGUAGE}} en code of the site's default interface language

Dependent on page

Word Example Explanation
{{PAGENAME}} Template Returns the name of the current page, including all levels (Title/Subtitle).
{{PAGENAMEE}} Template More URL-friendly percent encoded special characters (To use an articlename in an external link).
{{SUBPAGENAME}}
{{SUBPAGENAMEE}}
Template
Template
[MW1.6+] Name of the current page, excluding parent pages ("Subtitle" on "Title/Other/Subtitle") in namespaces supporting subpages, see Help:Link.
{{BASEPAGENAME}}
{{BASEPAGENAMEE}}
Template
Template
[MW1.7+] The basename of a subpage ("Title/Other" on "Title/Other/Subtitle"), see Help:Link.
{{NAMESPACE}}
{{NAMESPACEE}}
Help
Help
Returns the name of the namespace the current page resides in.
{{FULLPAGENAME}}
{{FULLPAGENAMEE}}
Help:Template
Help:Template
[MW1.6+] Shorthands for NAMESPACE+PAGENAME
{{TALKSPACE}}
{{TALKSPACEE}}
Help talk
Help_talk
[MW1.7+] Name of next odd namespace (e.g. 4 => 5)
{{SUBJECTSPACE}}
{{SUBJECTSPACEE}}
Help
Help
[MW1.7+] Name of last even namespace (e.g. 5 => 4)
{{ARTICLESPACE}}
{{ARTICLESPACEE}}
Help
Help
[MW1.7+] An alias for SUBJECTSPACE(E)
{{TALKPAGENAME}}
{{TALKPAGENAMEE}}
Help talk:Template
Help_talk:Template
[MW1.7+] FULLPAGENAME in its TALKSPACE
{{SUBJECTPAGENAME}}
{{SUBJECTPAGENAMEE}}
Help:Template
Help:Template
[MW1.7+] FULLPAGENAME in its SUBJECTSPACE
{{ARTICLEPAGENAME}}
{{ARTICLEPAGENAMEE}}
Help:Template
Help:Template
[MW1.7+] An alias for SUBJECTPAGENAME(E)
{{REVISIONID}} 16968578 [MW1.5+] The unique identifying number of a page, see Help:Diff. Note that when editing a page, this value is null.
{{REVISIONDAY}} 14 [MW1.8+] The day on which the page was last modified.
{{REVISIONDAY2}} 14 [MW1.8+] The day on which the page was last modified, but with a leading zero (01 .. 31).
{{REVISIONMONTH}} 11 [MW1.8+] The month in which the page was last modified.
{{REVISIONYEAR}} 2008 [MW1.8+] The year in which the page was last modified.
{{REVISIONTIMESTAMP}} 20081114184139 [MW1.8+] ISO 8601 time stamp, indicating when the page was last modified.
{{SITENAME}} AboutUs Value of $Sitename.
{{SERVER}} //aboutus.com Value of $Server
{{SCRIPTPATH}} [MW1.5+] $ScriptPath
{{SERVERNAME}} aboutus.com [MW1.5+] $ServerName