Simple Templates
Simple Templates
I view simple templates as those which do not use variables.
For the mh370wiki.net site I have a lot of useful components in the Template namespace. When these are transcluded into a page there is no need to include the namespace.
A Short Line
I frequently use a short line to separate parts of a page. The html horizontal line
is full width by default and has no significant white space before or after.
My ShortLine is simple and reusable:-
<includeonly><div style="margin-left:20%; margin-right:20%; margin-top:1em; margin-bottom:1em;"><hr></div></includeonly>
If there was nothing else on the source page then the includeonly tags would not be needed. But I have kept a few previous versions, where I adjusted the white space, between noinclude tags.
To use the ShortLine I just transclude it with this instruction:-
{{ShortLine}}
And the result is this:-
Sub-page List
I have used sub-pages a lot. Sometimes it is helpful to get a list of sub-pages somewhere on the top page, so I can see what exists; to easily link to and open a sub-page; to check that each sub-page is linked from a parent page.
To display the list of subpages I can just place this code at a suitable place on a parent page:-
{{SubpageList}}
The template looks like this:-
<hr>
<h5>Note: This article has sub-pages:-</h5>
<p>{{Special:PrefixIndex/{{FULLPAGENAME}}/}}</p>
FULLPAGENAME is a variable in MediaWiki. There is a list of 'magic words' and variables at https://www.mediawiki.org/wiki/Help:Magic_words
See also https://www.mediawiki.org/wiki/Help:Subpages
A Signature
To 'sign' an article with my name I just write:-
{{Signature}}
The template is simple:-
<p style="width:90%; margin-left: auto; margin-right: auto; font-size:1em; text-align:right;"><u>Grant</u></p>
The result is at the end of this page.
Category Pages
Category pages only need to belong to a parent category, but on the mh370wiki.net site I have used templates to provide extra information on each category page.
I have adapted the idea here and created a simple template named CategoryPage in the Template namespace:-
<onlyinclude>
<h2>Category: {{PAGENAME}}</h2>
<div class="header">
<p>This page lists matches for the category <i>{{PAGENAME}}</i>. To navigate to a higher level in the category hierarchy, use the link below the list of sub-categories or pages.</p>
</div> <!-- end header -->
<div style="margin-left:4.5em; margin-right:4.5em;">
<p style="margin-left:auto; margin-right:auto; text-align: justify;">{{{CategoryDescription| }}}</p>
</div>
</onlyinclude>
<includeonly>[[Category:{{{ParentCategory| }}}]]</includeonly>
For each template I also create instructions, like this:-
<h5>Usage</h5>
<p>Copy this code into each category page.</p>
{{CategoryPage
|ParentCategory=
|CategoryDescription=
}}
How it works
When the section between the {{ }} brackets is copied into an empty category page all you have to do is fill in the blanks after the =. Add the name of the parent category, and provide a description of what this current category is for.
The {{ }} brackets indicates that the enclosed section is to be transcluded. By default if a namespace is not stated then MediaWiki looks in the Template Namespace. There it will find the Template:CategoryPage and use the values for ParentCategory and CategoryDescription.
Grant