Template:Infobox block/doc: Difference between revisions

m Update doc for tntres
Document the "includable" style of block pages, and why it makes sense to use them.
Line 22: Line 22:
This template provides a uniform design for block pages.
This template provides a uniform design for block pages.
<pre width="30px">
<pre width="30px">
{{Block
&lt;onlyinclue&gt;{{ {{{1|Block}}}
|image=
|image=
|image2=
|image2=
Line 41: Line 41:
|fluidspeed=
|fluidspeed=
|movespeed=
|movespeed=
}}</pre>
}}&lt;/onlyinclude&gt;</pre>


Please note that if the item has multiple data values, use <code><nowiki>|multipledata=</nowiki></code> instead. See below:
Please note the unusual markup at the beginning and end; copy it verbatim if you are creating a new block page. Also note that if the item has multiple data values, use <code><nowiki>|multipledata=</nowiki></code> instead of <code><nowiki>|data=</nowiki></code>. See below:


{| class=grid style="background-color: transparent;"
{| class=grid style="background-color: transparent;"
Line 90: Line 90:
| <code>movespeed</code> || Speed of walking through || ''None''
| <code>movespeed</code> || Speed of walking through || ''None''
|}
|}
== Transcluding block pages ==
The unusual header <code><nowiki>&lt;onlyinclude&gt;{{ {{{1|Block}}}</nowiki></code> and footer are there so that block pages can be transcluded (used like templates) into other pages. Specifically, this allows the use of {{tl|Safe get}} to get specific data fields out of the infobox header in the block page. Here's some examples:
{| class="wikitable"
! Code
! Result
|-
| <code><nowiki>{{Safe get|Cobblestone|tntres}}</nowiki></code>
| {{Safe get|Cobblestone|tntres}}
|-
| <code><nowiki>{{Safe get|Cobblestone|tool}}</nowiki></code>
| {{Safe get|Cobblestone|tool}}
|-
| <code><nowiki>[[File:{{Safe get|Cobblestone|image}}]]</nowiki></code>
| [[File:{{Safe get|Cobblestone|image}}]]
|-
| <code><nowiki>{{Safe get|Cobblestone|non-existing field}}</nowiki></code>
| {{Safe get|Cobblestone|non-existing field}}
|-
| <code><nowiki>{{Safe get|Main Page|tntres}}</nowiki></code>
| {{Safe get|Main Page|tntres}}
|}
Although transcluding non-template pages is somewhat unusual, doing it this way allows all the data properties for a block to be defined in the infobox header, next to each other, and right where most people will think to look for them. At the same time, it allows us to make tables of values for things like [[Explosion#Blast_Resistance|Blast Resistance]] and [[Digging#Blocks_by_hardness|Hardness]] that auto-update whenever the main values are changed.
See {{tl|Blast Resistance Table}} for a simple example of how to use this functionality to automatically build tables.


== See also ==
== See also ==
{{Infobox see also}}
{{Infobox see also}}
{{doc/end}}
{{doc/end}}