Difference between revisions of "Template:Infobox/Doc"

450 bytes removed ,  08:01, 29 January 2022
no edit summary
 
(5 intermediate revisions by the same user not shown)
Line 24: Line 24:
|-
|-
...
...
|class="ibfobox-data-title"| ...
|class="infobox-data-title"| ...
|...
|...
|-
|-
Line 40: Line 40:
* In the code it looks like this: <code><nowiki>{{#if: {{{title|}}}|{{{title|}}}|{{PAGENAME}}}}</nowiki></code>
* In the code it looks like this: <code><nowiki>{{#if: {{{title|}}}|{{{title|}}}|{{PAGENAME}}}}</nowiki></code>
** the use of <code>#if:</code> [[mw:Help:Extension:ParserFunctions|parser function]] means that parameter is optional and won't work if it's not filled
** the use of <code>#if:</code> [[mw:Help:Extension:ParserFunctions|parser function]] means that parameter is optional and won't work if it's not filled
** <code><nowiki>{{PAGENAME}}</nowiki></code> [[mw:Help:Magic words|magic word]] in the function means that by default template uses title of the page it's used on
** <code><nowiki>{{PAGENAME}}</nowiki></code> [[mw:Help:Magic words|magic word]] in the function means that by default the template uses title of the page it's used on


<code>file</code> - for an image file
<code>file</code> - for an image file
* In the code: <code><nowiki>{{#if: {{{file|}}}|<tr><td colspan="2">[[File:{{{file|}}}{{!}}250px{{!}}center]]</td></tr>}}</nowiki></code>
* In the code: <code><nowiki>{{#if: {{{file|}}}|<tr><td colspan="2">[[File:{{{file|}}}{{!}}250px{{!}}center]]</td></tr>}}</nowiki></code>
** <code>#if:</code> once again means it's optional, but in this case there is no default value, in other words, if no image is provided there will nothing; otherwise function adds new row in the table, which will contain image
** <code>#if:</code> once again means it's optional, but in this case there is no default value, in other words, if no image is provided there will nothing; otherwise function adds new row in the table, which will contain image
** [[mw:Help:Images|wiki mark up for images]] sets how image will be formatted inside infobox, in this case it has fixed width - <code>250px</code>, and align - <code>center</code>, but these values can be set up as another pair of parameters
** [[mw:Help:Images|wiki mark up for images]] sets how image will be formatted inside the infobox, in this case it has fixed width - <code>250px</code>, and align - <code>center</code>, but these values can be set up as another pair of parameters
** only name of the file with format is needed
** only name of the file with format is needed


Line 82: Line 82:
To use infobox on another page, this code must be used:
To use infobox on another page, this code must be used:
<pre>
<pre>
{{infobox
{{Infobox
|title =
|title=
|file =  
|file=
|caption =  
|caption=
|prm1 =  
|prm1=something
|prm2 =  
|prm2=
}}</pre>{{Classic infobox
}}</pre>
|title =
|file =
|caption =
|prm1 =
|prm2 = }}
Per break down above, the only obligatory parameter here <code><nowiki>{{{prm1}}}</nowiki></code>.
Per break down above, the only obligatory parameter here <code><nowiki>{{{prm1}}}</nowiki></code>.


If everything is left empty, the output will be:
If everything is left empty, the output will be:


Code of filled up example:
{{Infobox
<pre>
|title=
{{infobox
|file=
|title = This is the title
|caption=
|file = De Alice's Abenteuer im Wunderland Carroll pic 15.jpg
|prm1=
|caption = How far into the template rabbit hole do you go?
|prm2=
|prm1 = Flowers
}}
|prm2 = Mushrooms}}</pre>
 
{{Classic infobox
|title = This is the title
|file = De Alice's Abenteuer im Wunderland Carroll pic 15.jpg
|caption = How far into the template rabbit hole do you go?
|prm1 = Flowers
|prm2 = Mushrooms}}
Gives:


<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |
[[Category:Infobox templates| ]]}}</includeonly>
[[Category:Infobox templates| ]]}}</includeonly>