Help:Template
Help: | Contents | Getting Started | New to BRWiki | Editing BRWiki | Editing BRWiki (advanced) | Communication and Community | Additional Help |
The help pages are currently being redesigned so they are more helpful. If you have any comments or are interested in helping out, please see the help team. |
|
[top]"Template:" vs Local Templates
- Using local templates makes life easier for yourself and for other editors, and it makes the "Template:" namespace less cluttered!
{{Sometemplate}}
while others use {{Template:Sometemplate}}
. This usually means the same thing; if you don't tell the wiki in which namespace to look, it will look under "Template:".Wait, what did I just say?
- A template does not have to live under "Template:". You can pull in a page from whereever into your page.
For site-wide templates, it makes sense to put them in the "Template:" namespace where everyone can find them, but for something that you're only using in a few pages, it makes much more sense to just put it in e.g. "MyPage/TheTemplate", and pull it in with
{{:MyPage/TheTemplate}}
.- Note the ":" at the beginning of
{{:MyPage/...
. Since most pages live in the "main" namespace of the wiki, we'd not be telling the wiki where to look for the page to include, so it'd go look in "Template:", where it wouldn't find much. ":" by itself means "Look in the main namespace, please".
You will have to use your own judgement for what's right for your template. Here's a few instructive examples though:
[top]Templates that belong in "Template:"
- Admin templates: {{Delete}}, {{Vote}}, {{Cleanup}}, ...
- General wiki helpers: {{clr}}, {{Infoline}}, {{tocright}}, ...
- General-purpose BR templates: {{gsc}}, {{Alliance Icon}}, ...
[top]Templates that perhaps didn't belong in "Template:"
- {{MiningOreTable}} - Only used in one page.
[top]Naming your template
This depends on where your template gets placed, really. And how commonly used you think it's going to be.
- Use dozens of times?
- Pick a short name.- Use a handful of times?
- Long, descriptive name. - Use a handful of times?
- In "Template:", a very commonly used template will likely be a single word, or two contracted words, all in lowercase. This makes it fast and easy to write. Examples include: {{clr}}, {{infoline}}, ... For instance, "BR API" should probably have been named simply "BRapi" -- much easier to write often.
- "Template:" templates that are more seldomly used will need a more descriptive name. But its name will still be fairly short.
- A locally stored template will typically be a subpage of something else, e.g. "My Page/My Template". Other than that, it can have just about any name.
- If it needs to be long winded and descriptive, make it so: {{Policy/Terminating/Direct termination terms}} (but you'll still go nuts if you need to include it in more than a handful of pages).
- Or be more brief; as long as you think people understand what the template is about when they stumble over it.
- If it needs to be long winded and descriptive, make it so: {{Policy/Terminating/Direct termination terms}} (but you'll still go nuts if you need to include it in more than a handful of pages).
[top]Explaining what your template does
It's very helpful to others (or, heck, yourself half a year from now!) to explain what your template actually does and why it exists. It's easy to put this information in the template without it pestering pages where it's included:
<noinclude>''This template does X and is used by Y. I made it a template because Z. --~~~~'' </noinclude> (and then the actual template...) |
This becomes even more important when your template uses parameters. Other people really appreciate it when you explain what order to input things.
[top]Templates have Talk pages too!
If there's more you'd like to say about your template than you care to explain between
[top]Tips and tricks
[top]Categories in templates
If you put a category in a template, all pages that use the template will suddenly end up in that category.Well, semi-suddenly anyway; the page needs to be edited once (just add a blank line or a space) before they're actually moved.
However, if you just go ahead and put in the category tag, your template will end up in the category too, which is maybe not what you intended. Use this:
<includeonly>[[Category:MyCategory]]</includeonly> |
[top]Template parameters
This is actually a fairly huge topic; we'll try to cut it short.MyTemplate: |
| |||
Using it: |
| |||
Results in: | Mommy, look! My template uses parameters! |
MyTemplate: |
| |||
Using it: |
| |||
Results in: | Mommy, look! My template uses parameters! |
MyTemplate: |
| |||
Using it: |
| |||
Results in: | Oi, look! My template uses parameter defaults!!! |
[top]Equal signs in parameter values
Since equal signs, "=", are part of how parameter values are supplied, they're a little bit troublesome. You can't supply equal signs to numbered parameters at all. However, you can supply them to named parameters:
{{MyTemplate|Haha =)}} |
This will probably not work like you intended. You're setting the parameter "Haha" to ")". Not "1" to "Haha =)".
{{MyTemplate|text=Haha =)}} |
This example sets the parameter "text" to "Haha =)".
[top]Templates can use templates!
When your templates are getting big, chances are you want to re-use something from one template in another template.- Just cut the common parts out and paste them into a new template and then use that template in other templates!
There's also other reasons why you may want to use sub-templates. See e.g. {{Delete}} and {{Delete/Content}}. Pulling in "Delete" automatically marks the page for deletion, but Delete also wants to show what it looks like without getting itself marked for deletion, so it just pulls in "Delete/Content".
[top]Splitting templates into a /Begin and /End
- For an example of split templates, see {{Example/Begin}} and {{Example/End}}.
- Of course, {{Example}} pulls them both in for places where you don't need the extra oomph.
- See {{Code/Begin}}, {{Code/End}} and {{Code}} for more advanced use.
- Note: You cannot begin a HTML tag in one template and end it in another. The MediaWiki software refuses to leave HTML tags unfinished in a page, so it helpfully ends them for you right at the end of the "Begin" snippet, long before they're of any use to you.
| « This won't work! |
- Wiki-style tables, on the other hand, can be begun in one template and ended in another.
| « This will work! |
[top]Categorize your templates!
It helps other editors (and probably yourself, too!) if you categorize your templates themselves. Perhaps not so much for "Template:" templates, but definitely for local templates!Pages that use a local template will likely share one or more common categories, so making a "Your Category/Templates" and putting the templates there helps other editors find them easily!
Example: |
|
- Make sure that pages using your template don't end up in the "/Templates" category!
[[Category: My Category/Templates]] (and then the actual template...) |
There is a number of built-in variables that are very useful for templates.
One such is {{PAGENAME}}, which for this page is "Template". So all base zone pages could for instance use a template that pulls in ":{{PAGENAME}}/Boss list", and links to "{{PAGENAME}}/Loot list". But attempting to use that template inside one of the subpages would break horribly.
[top]Other resources
- Templates. Common templates in use in BRWiki!
- Templates. Nearly everything in the "Template:" namespace, categorized in subcategories.
- The old version of this page. (Quite different)
[top]Pages with lots of templates not updating
When a page pulls in lots of templates, it won't always update when a template changes. There are two ways to force a refresh:
This problem should be alleviated as of the MediaWiki 1.7 upgrade. The wiki software will attempt to update many of the pages using the template immediately, but if there's too many to do immediately, it'll spread the work over the next few minutes.
Is anything on this page unclear? Or is there something you'd like to know more about? - Drop a line in the Talk page! It's on my watchlist. --Mikk 05:25, 26 May 2006 (EDT)
- Do a dummy edit on the page
- Do "action=purge" on the page, e.g. http://www.birthright.netTemplate:localurl:help:template
- The {{purge|
}} template creates such a link in the page itself.
- The {{purge|
This problem should be alleviated as of the MediaWiki 1.7 upgrade. The wiki software will attempt to update many of the pages using the template immediately, but if there's too many to do immediately, it'll spread the work over the next few minutes.
Is anything on this page unclear? Or is there something you'd like to know more about? - Drop a line in the Talk page! It's on my watchlist. --Mikk 05:25, 26 May 2006 (EDT)
Contributors: | ,
Created by Last edited by , 10-23-2011 at 03:02 PM 0 Comments, 5,186 Views |
, 01-12-2007 at 08:58 PM
Tags for this Page
Similar Pages
-
Single Feat Template
By Sorontar in forum MainComments: 0Last Post: 11-28-2006, 01:50 AM -
Template
By Arjan in forum MainComments: 0Last Post: 11-27-2006, 08:55 PM
Bookmarks