Introduction to Templates
From Gumnickopedia
|
Templates are pages that can be set up to contain some text or coding that you’re likely to use over and over again. They’re a convenient way to avoid “reinventing the wheel” when you want to put pages in columns, add a footer to several pages, format several blocks of text the same way, and so on. You can recognize templates from the curly brackets that enclose their names. For example, many pages in the site use a set of templates with names like {{Col1/2}}, {{Col2/2}}, {{Col1/3}}, {{ColEnd}}, etc., to arrange content in multiple columns. The same effect can be achieved with Wiki tab coding or conventional HTML coding, but I thought it would be helpful to place this potentially confusing (and easily broken) code into template files to make editing the pages simpler. Some templates have additional parameters that you need to supply. For instance, the Who said that? page uses the template called {{Quotations}} to construct the box around each item, place the quotation marks, and supply the styles of the quotation and its attribution. When you edit the code on that page, you’ll see the {{Quotations code followed by several lines of additional parameters that look like this:
{{Quotation|
|framecolor=fuchsia
|framesize=2
|quotation=Awwww…. Look at Mom’s Phanny on Dad’s lap!
|attribution=Jane
|note=
}}
On each of the lines after the first one, the word between the “pipe” (|) character and the equals sign is the name of a variable in the template, and whatever comes after the equals sign is the value you’re assigning to that variable. Notice that the note variable has no value, because this quotation has no note of explanation. (You could omit the
|
I’ve set up a new template to put a small headline and a block of text in a shaded box. Copy the following code, and place it on any page where you’d like to try it out:
{{Simple box|
|boxcolor=beige
|headcolor=darkblue
|head=Here is the Headline
|textcolor=maroon
|text=And this is the text.
}}
which produces the following results:
With this particular template, the head and text parameters require values to make the box look right. The color parameters are optional, but you’ll get some funky results if you don’t specify colors. You can include other formatting elements within the head and text values. For instance, this code:
{{Simple box|
|boxcolor=palegreen
|headcolor=darkgreen
|head=Here is the Headline
|textcolor=black
|text=[[Image:save_button.gif|left]]And this is the text,
which includes a “Save page” button graphic.
}}
produces the following results:
|
Categories: Authoring | Editing | Help | Reference | Site Management

