149
edits
(Created page with "{{documentation subpage}} This is an example of '''classic infobox template''' - a simple infobox coded as table. It was copied from https://template.miraheze.org/wiki/Template:Classic_infobox == Overview == === Table === Infobox is a '''table'''. There is two ways to build tables on wiki spaces - using HTML mark up (tags) or using wiki mark up. Here HTML tags were used: <pre> <table class="infobox"> <tr><td colspan="2" style="text-align: center; font-size:140%;">....") |
|||
| (10 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
This is an example of '''infobox template''' - a simple infobox coded as table. It was copied from https://template.miraheze.org/wiki/Template:Classic_infobox | |||
This is an example of ''' | |||
== Overview == | == Overview == | ||
| Line 12: | Line 11: | ||
... | ... | ||
<tr> | <tr> | ||
<td class=" | <td class="infobox-data-title">...</td> | ||
<td class=" | <td class="infobox-data">...</td> | ||
</tr> | </tr> | ||
... | ... | ||
| Line 25: | Line 24: | ||
|- | |- | ||
... | ... | ||
|class=" | |class="infobox-data-title"| ... | ||
|... | |... | ||
|- | |- | ||
| Line 38: | Line 37: | ||
This example infobox has 5 parameters: | This example infobox has 5 parameters: | ||
<code>title</code> - | <code>title</code> - used to force custom text in a header of infobox | ||
* 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 | * 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 60: | Line 59: | ||
<code>prm1</code> - second data parameter, with "Parameter 2" title | <code>prm1</code> - second data parameter, with "Parameter 2" title | ||
* In the code:<br><code><nowiki>{{#if: {{{prm2|}}}|<tr> | * In the code:<br><code><nowiki>{{#if: {{{prm2|}}}|<tr> | ||
<td class=" | <td class="infobox-data-title">Parameter 2</td> | ||
<td class=" | <td class="infobox-data">{{{prm2}}}</td> | ||
</tr>}}</nowiki></code> | </tr>}}</nowiki></code> | ||
** <code>#if:</code> again means it's optional, but if filled it will add a row with two columns | ** <code>#if:</code> again means it's optional, but if filled it will add a row with two columns | ||
| Line 70: | Line 69: | ||
* and several '''classes''' | * and several '''classes''' | ||
** <code>infobox</code> for entire table - this wiki already has such class in [[MediaWiki:Common.css|Common.css]] page; most notably it puts the box into right side of the page and gives it background color and border | ** <code>infobox</code> for entire table - this wiki already has such class in [[MediaWiki:Common.css|Common.css]] page; most notably it puts the box into right side of the page and gives it background color and border | ||
** <code> | ** <code>infobox-data-title</code> - for column with data titles; will be a custom class in [[Template:Classic infobox/styles.css]] page - for educational purposes it will brighter than usual Wikipedia style | ||
** <code> | ** <code>infobox-data</code> - for second column, with data values; same as previous | ||
===Categories=== | ===Categories=== | ||
| Line 83: | 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 | ||
|title = | |title= | ||
|file = | |file= | ||
|caption = | |caption= | ||
|prm1 = | |prm1=something | ||
|prm2 = | |prm2= | ||
}}</pre> | }}</pre> | ||
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: | ||
{{Infobox | |||
|title= | |||
{{ | |file= | ||
|title = | |caption= | ||
|file = | |prm1= | ||
|caption = | |prm2= | ||
|prm1 = | }} | ||
|prm2 = | |||
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | | | <includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | | | ||
[[Category:Infobox templates| ]]}}</includeonly> | [[Category:Infobox templates| ]]}}</includeonly> | ||