Help:Templates: Difference between revisions

Jump to navigation Jump to search
192 bytes added ,  5 March 2023
m
& deprecated
m (→‎Documentation Subpages: updating old info)
m (& deprecated)
 
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Header Nav|game=StrategyWiki:Guide}}
{{Header Nav|game=StrategyWiki:Guide}}
{{floatingtoc}}
:''Template redirects here. For a list of templates see [[:Category:Templates]]''
:''Template redirects here. For a list of templates see [[:Category:Templates]]''
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 10: Line 11:
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 (increasing the server workload), 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.
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 (increasing the server workload), 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 {{t|Game}} 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.


=== Documentation Sub-pages ===
=== Documentation Sub-pages ===
When a template becomes widely used, such as [[:Template:Infobox]], it's necessary to move the documentation (a.k.a. explanation) of the template to another page.  By doing this, it allows users to modify the examples and explanations while not increasing the job queue.
When a template becomes widely used, such as {{t|Game}}, it's necessary to move the documentation (a.k.a. explanation) of the template to another page.


Rules for creating a documentation subpage:
Rules for creating a documentation subpage:
*First, start <nowiki><noinclude></nowiki> tags immediately after the template code ends. This is followed by the {{t|Documentation}} template, which automatically transcludes the documentation page and a link to it. After adding the <nowiki>[[Category:Templates|{{PAGENAME}}]] or [[Category:Guide-specific templates|{{PAGENAME}}]]</nowiki> category, close the <nowiki></noinclude></nowiki> tag.
*First, start <nowiki><noinclude></nowiki> tags immediately after the template code ends. This is followed by the {{t|Documentation}} template, which automatically transcludes the documentation page and a link to it. After adding the <nowiki>[[Category:Templates|{{subst:PAGENAME}}]] or [[Category:Guide-specific templates|{{subst:PAGENAME}}]]</nowiki> category, close the <nowiki></noinclude></nowiki> tag.
*The documentation sub-page must be titled "Documentation", as in [[Template:Infobox/Documentation]]. After adding the {{t|Documentation}} template, you can click the red link it creates to go to the properly named page.
*The documentation sub-page must be titled "Documentation", as in [[Template:Game/Documentation]]. After adding the {{t|Documentation}} template, you can click the red link it creates to go to the properly named page.
*The sub-page should be categorized by <nowiki>[[Category:Template documentation|{{PAGENAME}}]], surrounded by <noinclude> tags</nowiki>.
*The sub-page should be categorized by <nowiki>[[Category:Template documentation|{{subst:PAGENAME}}]], surrounded by <noinclude> tags</nowiki>.


==Using a template==
==Using a template==
Line 117: Line 118:
The user can then simply copy and paste the template for use. Make sure to use '''<nowiki><noinclude></nowiki>''' tags around everything from the end of the tempate code to the end of the page.
The user can then simply copy and paste the template for use. Make sure to use '''<nowiki><noinclude></nowiki>''' tags around everything from the end of the tempate code to the end of the page.
== 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 [[:Template:Infobox]] and [[:Template:Final Fantasy VII/Boss]].
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 {{t|Game}} 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.
Note: use <nowiki>{{!}}</nowiki> to replace the use of pipes (the "|" character). If you don't, the conditional argument (e.g. <nowiki>{{#if:}}</nowiki>) will end abruptly.  Typically, <nowiki>{{!}}</nowiki> is used when generating new rows of a table (HTML TR/TD) within a conditional argument.


=== <nowiki>{{#if:}}</nowiki> ===
=== <nowiki>{{#if:}}</nowiki> ===
Line 345: Line 348:
|}
|}


{{Footer Nav|game=StrategyWiki:Guide|prevpage=Advanced tables|nextpage=Walkthrough}}
{{Footer Nav|game=StrategyWiki:Guide|prevpage=Regular expressions|nextpage=Walkthrough}}

Navigation menu