Template:Fn: Difference between revisions
No edit summary |
No edit summary |
||
Line 5: | Line 5: | ||
|the Rani=[[the Rani]] | |the Rani=[[the Rani]] | ||
|the Monk=[[the Monk]] | |the Monk=[[the Monk]] | ||
|#default={{{1}}} | |#default={{{1}}}{{!}}{{#explode:{{{1}}}| |0}} | ||
}} | }} | ||
</includeonly><noinclude>{{documentation}}[[Category:Coding utility templates]]</noinclude> | </includeonly> | ||
[[Francine Jones|{{#explode:Francine Jones| |0}}]] | |||
<noinclude>{{documentation}}[[Category:Coding utility templates]]</noinclude> |
Revision as of 02:50, 4 February 2014
This template isn't super useful on its own. For instance, if you type {{fn|Martha Jones}}, you'll merely get Martha Jones|Martha
Francine — which doesn't do you a whole lot of good.
But, within templates, where you can preset the brackets, it's highly useful to automated processes.
Usage is along the lines of:
[[{{fn|{{{variable name}}}]]
In the typical infobox, you'll have a variable and value, which this template can usefully handle. For instance, within {{Infobox Individual}}, you have:
{|Infobox Individual |name=Leo Jones |sister=Martha Jones |sister-Tish Jones |}
If you set {{Infobox Individual}} to correctly process this input as an SMW variable — but want it to show only a linked first name, the guts of the code would be this:
[[sister::{{fn|{{{sister}}}}}]] [[sister::{{fn|{{{sister2}}}}}]]
This, when mixed with a tiny bit more formatting, would result in the following displaying in the infobox: Martha, Tish. Meanwhile, Property:Sister for Leo Jones would return Martha Jones and Tish Jones.
Exceptions
Because this wiki covers the DWU, we have to make exceptions for characters who don't have normal names. In particular, the DWU has a lot of characters, starting with the titular one, whose names are in the format of "the <whatever>". Lucikly this template uses a #switch core, so we can easily set up exceptions, where we directly define how we want to handle certain, specific names to be handled — but then otherwise let the template cascade down to the #default way of doing things.
If you encounter a character who has an "odd" name, like Jack's mother (Kept Safe and Sound), you'll have to add an exception to the code of this template. To do so, just create a new line above the line that begins with |#default=. On that line, set the "odd" name equal to whatever term you'd like to use. So, for the example above, you'd just add this:
|Jack's mother (Kept Safe and Sound)=Jack's mother (Kept Safe and Sound){{!}}Jack's mother