Template:Infobox block/doc: Difference between revisions

No edit summary
No edit summary
Line 9: Line 9:
This template provides a uniform design for block pages.
This template provides a uniform design for block pages.
<pre width="30px">
<pre width="30px">
&lt;onlyinclude&gt;{{ {{{1|Block}}}
{{Block
|title=
|title=
|image=
|image=
Line 43: Line 43:
|firstver=
|firstver=
|notes=
|notes=
}}&lt;/onlyinclude&gt;</pre>
}}</pre>


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:
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:
Line 120: Line 120:
| <code>notes</code> || Adds a centred column spanning across both rows at the bottom of the box || ''None''
| <code>notes</code> || Adds a centred column spanning across both rows at the bottom of the box || ''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 ==