Jump to navigation
Jump to search
The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.
Latest revision | Your text | ||
Line 1: | Line 1: | ||
{{Header Nav|game=StrategyWiki:Guide}} | {{Header Nav|game=StrategyWiki:Guide}} | ||
:''Template redirects here, for a list of templates see [[:Category:Templates]]'' | |||
:''Template redirects here | |||
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). | 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). | ||
Line 11: | Line 10: | ||
Every template must be placed within a category, either [[:Category:Templates]] or [[:Category:Guide-specific templates]]. | Every template must be placed within a category, either [[:Category:Templates]] or [[:Category:Guide-specific templates]]. | ||
If you want to modify a template it's usually good to discuss it within the talk page if it's a major change. Making multiple changes to templates used on multiple pages can cause disastrous effects and bog down the job queue | If you want to modify a template it's usually good to discuss it within the talk page if it's a major change. Making multiple changes to templates used on multiple pages can cause disastrous effects and bog down the job queue, so it's best to discuss changes on the talk page or try your idea in a sandbox before any changes are made. Most widely-used templates, like [[Template:Infobox]] are protected to avoid this, so a discussion is the perfect way to get your ideas heard. Protected templates will require a [[StrategyWiki:Administrators|sysop/admin]] to make the change. | ||
Categorization, careful naming, and maintaining a hierarchy is key in ensuring that our templates don't get cluttered. Templates are critical for reducing redundancy, but they are powerful tools that must be given respect and much thought so that they don't in themselves become redundant. | Categorization, careful naming, and maintaining a hierarchy is key in ensuring that our templates don't get cluttered. Templates are critical for reducing redundancy, but they are powerful tools that must be given respect and much thought so that they don't in themselves become redundant. | ||
==Using a template== | ==Using a template== | ||
Line 65: | Line 56: | ||
==Control template inclusion== | ==Control template inclusion== | ||
You can control template inclusion by the use of <code> | You can control template inclusion by the use of <code><nowiki><noinclude></nowiki></code> and | ||
<code><nowiki><includeonly></nowiki></code> tags. | |||
Anything between <code> | Anything between <code><nowiki><noinclude></nowiki></code> and <code><nowiki></noinclude></nowiki></code> will be processed and | ||
displayed only when the page is being viewed directly, not included. | |||
Possible applications are: | Possible applications are: | ||
Line 74: | Line 67: | ||
* Explanatory text about how to use the template | * Explanatory text about how to use the template | ||
The converse is <code> | The converse is <code><nowiki><includeonly></nowiki></code>. Text between <code><nowiki><includeonly></nowiki></code> and | ||
<code><nowiki></includeonly></nowiki></code> 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 | Note that the usual update problems apply -- if you change the | ||
Line 85: | Line 75: | ||
won't be updated until those pages are edited. | won't be updated until those pages are edited. | ||
==Making templates useful== | ==Making templates useful== | ||
For templates to be effective | For templates to be effective users need to find them and be able to use them. Wikis are not user friendly when it comes to finding, using, and working with templates. A simple technique is to have a usage on the template page. | ||
For example | |||
<div style=" | <div style="display:table; width:auto;"> | ||
== Advanced template usage == | == Advanced template usage == | ||
We already covered parameters, think of them as variables (temporarily stored data). MediaWiki allows us to look at those variables and check if they even contain anything. What this lets us do is create templates in which only certain parts appear if the data exists within them, for instance in | We already covered parameters, think of them as variables (temporarily stored data). MediaWiki allows us to look at those variables and check if they even contain anything. What this lets us do is create templates in which only certain parts appear if the data exists within them, for instance in [[:Template:Infobox]] and [[:Template:Final Fantasy VII/Boss]]. | ||
The <nowiki>{{#if:}}</nowiki> function is what lets us manipulate wiki code in this way. We can test for existence within a parameter, then display a certain text if it exists, and a certain text if it doesn't. This way we can display and hide text when empty spaces would normally exist. Other parser functions like <nowiki>{{#if:}}</nowiki> exist and are used for different purposes. Usage of these functions is outlined below. | The <nowiki>{{#if:}}</nowiki> function is what lets us manipulate wiki code in this way. We can test for existence within a parameter, then display a certain text if it exists, and a certain text if it doesn't. This way we can display and hide text when empty spaces would normally exist. Other parser functions like <nowiki>{{#if:}}</nowiki> exist and are used for different purposes. Usage of these functions is outlined below. | ||
=== <nowiki>{{#if:}}</nowiki> === | === <nowiki>{{#if:}}</nowiki> === | ||
Line 343: | Line 302: | ||
|<pre>{{#switch:hello|HELLO=foo = 1|hello|hi|Hello=bar = 2|#default=baz = 3}}</pre> | |<pre>{{#switch:hello|HELLO=foo = 1|hello|hi|Hello=bar = 2|#default=baz = 3}}</pre> | ||
|{{#switch:hello|HELLO=foo = 1|hello|hi|Hello=bar = 2|#default=baz = 3}} | |{{#switch:hello|HELLO=foo = 1|hello|hi|Hello=bar = 2|#default=baz = 3}} | ||
|} | |} | ||
{{Footer Nav|game=StrategyWiki:Guide|prevpage= | {{Footer Nav|game=StrategyWiki:Guide|prevpage=Tables|nextpage=Preview and save}} | ||
</div> |