Jump to content

Template:Infobox/doc: Difference between revisions

→‎See also: update category
(words)
(→‎See also: update category)
Line 1: Line 1:
{{distinguish|Template:Userbox}}
{{distinguish|Template:Userbox}}
{{Documentation subpage}}
{{Documentation subpage}}
<includeonly>{{#ifeq:{{#titleparts:{{PAGENAME}}|1|2}}|old ||{{High-use|3408796}}{{Lua|Module:Infobox}}}}</includeonly>
<includeonly>{{#ifeq:{{#titleparts:{{PAGENAME}}|1|2}}|old ||{{High-use|3408796|all-pages=yes}}{{Lua|Module:Infobox}}}}</includeonly>
{{Parameter names example
{{Parameter names example
  |name={{PAGENAME}} <!--|child |subbox |decat--> |title |above |subheader |subheader1 |subheader2={{{subheader2}}}<br/>......
  |name={{PAGENAME}} <!--|child |subbox |decat--> |title |above |subheader |subheader1 |subheader2={{{subheader2}}}<br/>......
Line 15: Line 15:
}}
}}


This template is intended as a meta template: a template used for constructing other templates. '''Note''': In general, it is not meant for use directly in an article, but can be used on a one-off basis if required. [[Help:Infobox]] contains an introduction about the recommended content and design of infoboxes; [[Imamatpedia:Manual of Style/Infoboxes]] contains additional style guidelines. See [[WP:List of infoboxes]] and [[:Category:Infobox templates]] for lists of prepared topic-specific infoboxes.
This template is intended as a meta template: a template used for constructing other templates. '''Note''': In general, it is not meant for use directly in an article, but can be used on a one-off basis if required. [[Help:Infobox]] contains an introduction about the recommended content and design of infoboxes; [[imamatpedia:Manual of Style/Infoboxes]] contains additional style guidelines. See [[WP:List of infoboxes]] and [[:Category:Infobox templates]] for lists of prepared topic-specific infoboxes.


== Usage ==
== Usage ==
Line 25: Line 25:
| name    = {{{name|{{PAGENAME}}}}}
| name    = {{{name|{{PAGENAME}}}}}
| image    = {{{image|}}}
| image    = {{{image|}}}
| caption1 = {{{caption|}}}}}}
| caption1 = {{{caption|}}}


| label1  = Former names
| label1  = Former names
Line 39: Line 39:


== Optional control parameters ==
== Optional control parameters ==
; name : If this parameter is present, "view/discuss/edit" links will be added to the bottom of the infobox pointing to the named page. You may use the value <nowiki>{{subst:PAGENAME}}</nowiki>; however, this is rarely what you want because it will send users clicking these links in an infobox to the template code rather than the data in the infobox they probably want to change.
; name : If this parameter is present, "view/talk/edit" links will be added to the bottom of the infobox pointing to the named page. You may use the value <nowiki>{{subst:PAGENAME}}</nowiki>; however, this is rarely what you want because it will send users clicking these links in an infobox to the template code rather than the data in the infobox they probably want to change.
; child :  See the [[#Embedding|Embedding]] section for details. If this is set to "yes", this child infobox should be titled but have no name parameter. This parameter is empty by default, set it to "yes" to activate it.
; child :  See the [[#Embedding|Embedding]] section for details. If this is set to "yes", this child infobox should be titled but have no name parameter. This parameter is empty by default, set it to "yes" to activate it.
; subbox :  See the [[#Subboxes|Subboxes]] section for details. If this is set to "yes", this subbox should be titled but have no name parameter. This parameter is empty by default, set to "yes" to activate it. It has no effect if the '''child''' parameter is also set to "yes".
; subbox :  See the [[#Subboxes|Subboxes]] section for details. If this is set to "yes", this subbox should be titled but have no name parameter. This parameter is empty by default, set to "yes" to activate it. It has no effect if the '''child''' parameter is also set to "yes".
; decat : If this is set to "yes", the current page will not be autocategorized in a maintenance category when the generated infobox has some problems or no visible data section. Leave empty by default or set to "yes" to activate it.
; decat : If this is set to "yes", the current page will not be autocategorized in a maintenance category when the generated infobox has some problems or no visible data section. Leave empty by default or set to "yes" to activate it.
; autoheaders: If this is set to any non-blank value, headers which are not followed by data fields are suppressed.  See the "[[#Hiding headers when all its data fields are empty|hiding headers when all its data fields are empty]]" section for more details.


== Content parameters ==
== Content parameters ==
Line 49: Line 50:
There are two different ways to put a title on an infobox. One contains the title inside the infobox's border in the uppermost cell of the table, the other puts it as a caption on top of the table. You can use them both together, or just one or the other, or neither (though this is not recommended):
There are two different ways to put a title on an infobox. One contains the title inside the infobox's border in the uppermost cell of the table, the other puts it as a caption on top of the table. You can use them both together, or just one or the other, or neither (though this is not recommended):


; title : Text to put in the caption over the top of the table (or as section header before the whole content of this table, if this is a child infobox). For [[Imamatpedia:Manual of Style/Accessibility#Tables|accessibility reasons]], this is the most recommended alternative.
; title : Text to put in the caption over the top of the table (or as section header before the whole content of this table, if this is a child infobox). For [[imamatpedia:Manual of Style/Accessibility#Tables|accessibility reasons]], this is the most recommended alternative.
; above : Text to put within the uppermost cell of the table.
; above : Text to put within the uppermost cell of the table.
; subheader(n) : additional title fields which fit below {{{title}}} and {{{above}}}, but before images.
; subheader(n) : additional title fields which fit below {{{title}}} and {{{above}}}, but before images.
Line 139: Line 140:
For more on #if, see [[meta:ParserFunctions##if:|here]].
For more on #if, see [[meta:ParserFunctions##if:|here]].


==== Hiding headers when all data fields are hidden ====
==== Hiding headers when all its data fields are empty ====
You can also make headers optional in a similar way. Consider this example:
You can also make headers automatically hide when their section is empty (has no data-row showing).
 
Consider this situation:
{{Infobox
{{Infobox
  | title  = Example of an undesirable header
  | title  = Example: header with & without data
  | header1 = Undesirable header
| headerstyle = background:lightgrey
  |  label2 = Item 1      |  data2 =
 
  |  label3 = Item 2      |  data3 =
  | header1 = Header1 with empty section
  |  label4 = Item 3      |  data4 =
  |  label2 = label2 text |  data2 =
  | header5 = Static header
  |  label3 = label3 text |  data3 =
  |  label6 = Static item |  data6 = Static value
  |  label4 = label4 text |  data4 =
 
  | header5 = Header5 with data below
  |  label6 = label6 text |  data6 = Some value
}}
}}
<pre style="overflow:auto">
<pre style="overflow:auto">
{{Infobox
{{Infobox
  | title  = Example of an undesirable header
  | title  = Example: header with & without data
  | header1 = Undesirable header
| headerstyle = background:lightgrey
  |  label2 = Item 1      |  data2 =
 
  |  label3 = Item 2      |  data3 =
  | header1 = Header1 with empty section
  |  label4 = Item 3      |  data4 =
  |  label2 = label2 text |  data2 =
  | header5 = Static header
  |  label3 = label3 text |  data3 =
  |  label6 = Static item |  data6 = Static value
  |  label4 = label4 text |  data4 =
 
  | header5 = Header5 with data below
  |  label6 = label6 text |  data6 = Some value
}}
}}
</pre>{{clear}}
</pre>{{clear}}


If you want the first header to appear only if one or more of the data fields that fall under it are filled, one could use the following pattern as an example of how to do it:
If you want hide the header when no {{para|data''N''}} values are present, use '''{{para|autoheaders|y}}''':
 
{{Infobox
| title  = Example: header with & without data
| autoheaders = y
| headerstyle = background:lightgrey
 
| header1 = Header1 with empty section
|  label2 = label2 text |  data2 =
|  label3 = label3 text |  data3 =
|  label4 = label4 text |  data4 =
 
| header5 = Header5 with data below
|  label6 = label6 text |  data6 = Some value
}}


<syntaxhighlight lang="moin" style="overflow:auto">
{{Infobox
{{Infobox
  | title  = Example of an optional header
  | title  = Example: header with & without data
  | header1 = {{ #if: {{{item1|}}}{{{item2|}}}{{{item3|}}} | Optional header }}
| autoheaders = y
  |  label2 = Item 1      |  data2 = {{{item1|}}}
  | headerstyle = background:lightgrey
  |  label3 = Item 2      |  data3 = {{{item2|}}}
 
  |  label4 = Item 3      |  data4 = {{{item3|}}}
| header1 = Header1 with empty section
  | header5 = Static header
  |  label2 = label2 text |  data2 =
  |  label6 = Static item |  data6 = Static value
  |  label3 = label3 text |  data3 =
  |  label4 = label4 text |  data4 =
 
  | header5 = Header5 with data below
  |  label6 = label6 text |  data6 = Some value
}}
}}
<source lang="moin" style="overflow:auto">
</syntaxhighlight>{{clear}}
 
So, header1 will be shown if any of item1, item2, or item3 is defined. If none of the three parameters are defined the header won't be shown and no empty row appears before the next visible content.
 
Note: if the data has empty css elements, like {{para|data|2=&lt;span style="background:yellow;">&lt;/span>}}, this will be treated as non-empty (having data).
 
If {{para|autoheaders|y}} but there are items that you ''do not'' want to trigger a header, place {{para|headerX|_BLANK_}}. This will serve as an empty header and separate it from the subsequent items.
 
{{Infobox
{{Infobox
  | title  = Example of an optional header
  | title  = Example: blank header with & without data
  | header1 = {{ #if: {{{item1|}}}{{{item2|}}}{{{item3|}}} | Optional header }}
  | autoheaders = y
  |  label2 = Item 1      |  data2 = {{{item1|}}}
| headerstyle = background:lightgrey
  |  label3 = Item 2      |  data3 = {{{item2|}}}
 
  |  label4 = Item 3      |  data4 = {{{item3|}}}
| header1 = Header1 with empty section
  | header5 = Static header
  |  label2 = label2 text |  data2 =
  |  label6 = Static item |  data6 = Static value
  |  label3 = label3 text |  data3 =
  |  label4 = label4 text |  data4 =
 
  | header5 = _BLANK_
  |  label6 = label6 text |  data6 = Some value, but does not trigger header1 or show header5
}}
}}
</source>{{clear}}


header1 will be shown if any of item1, item2, or item3 is defined. If none of the three parameters are defined the header won't be shown and no empty row appears before the next static content. The trick to this is that the <code>#if</code> returns false only if there is nothing whatsoever in the conditional section, so only if all three of item1, item2 and item3 are undefined will the if statement fail.
<syntaxhighlight lang="moin" style="overflow:auto">
{{Infobox
| title  = Example: header with & without data
| autoheaders = y
| headerstyle = background:lightgrey


Note that such trick may be sometimes very complex to test if there are many data items whose value depends on complex tests (or when a data row is generated by a recursive invokation of this template as a [[#Subboxes|subbox]]). Ideally, the Lua module supporting this template should now support a new way to make each header row autohideable by detecting if there is at least one non-empty data row after that header row (a parameter like {{para|autohide header1 | yes}}, for example, would remove the need to perform the <code>#if</code> test so that we can just to define {{para|header1 | Optional header}}),
| header1 = Header1 with empty section
|  label2 = label2 text |  data2 =
|  label3 = label3 text |  data3 =
|  label4 = label4 text |  data4 =
 
| header5 = _BLANK_
|  label6 = label6 text |   data6 = Some value, but does not trigger header1 or show header5
}}
</syntaxhighlight>{{clear}}


=== Footer ===
=== Footer ===
Line 202: Line 252:


=== CSS styling ===
=== CSS styling ===
{{div col}}
; bodystyle : Applies to the infobox table as a whole
; bodystyle : Applies to the infobox table as a whole
; titlestyle : Applies only to the title caption. Adding a background color is usually inadvisable since the text is rendered "outside" the infobox.
; titlestyle : Applies only to the title caption. Adding a background color is usually inadvisable since the text is rendered "outside" the infobox.
Line 209: Line 260:
; rowstyle(n) : This parameter is inserted into the <code>style</code> attribute for the specified row.
; rowstyle(n) : This parameter is inserted into the <code>style</code> attribute for the specified row.
; headerstyle : Applies to all header cells
; headerstyle : Applies to all header cells
; subheaderstyle : Applies to all subheader cells
; labelstyle : Applies to all label cells
; labelstyle : Applies to all label cells
; datastyle : Applies to all data cells
; datastyle : Applies to all data cells
; belowstyle : Applies only to the below cell
; belowstyle : Applies only to the below cell
{{div col end}}


=== HTML classes and microformats ===
=== HTML classes and microformats ===
{{div col}}
; bodyclass : This parameter is inserted into the <code>class</code> attribute for the infobox as a whole.
; bodyclass : This parameter is inserted into the <code>class</code> attribute for the infobox as a whole.
; titleclass : This parameter is inserted into the <code>class</code> attribute for the infobox's '''title''' caption.
; titleclass : This parameter is inserted into the <code>class</code> attribute for the infobox's '''title''' caption.
Line 230: Line 284:
-->
-->
; belowclass : This parameter is inserted into the <code>class</code> attribute for the infobox's '''below''' cell.
; belowclass : This parameter is inserted into the <code>class</code> attribute for the infobox's '''below''' cell.
{{div col end}}


This template supports the addition of microformat information. This is done by adding "class" attributes to various data cells, indicating what kind of information is contained within. Multiple class names may be specified, separated by spaces, some of them being used as selectors for custom styling according to a project policy or to the skin selected in user preferences, others beig used for microformats.
This template supports the addition of microformat information. This is done by adding "class" attributes to various data cells, indicating what kind of information is contained within. Multiple class names may be specified, separated by spaces, some of them being used as selectors for custom styling according to a project policy or to the skin selected in user preferences, others being used for microformats.


To flag an infobox as containing [[hCard]] information, for example, add the following parameter:
To flag an infobox as containing [[hCard]] information, for example, add the following parameter:
Line 249: Line 304:
...and so forth. "above" and "title" can also be given classes, since these are usually used to display the name of the subject of the infobox.
...and so forth. "above" and "title" can also be given classes, since these are usually used to display the name of the subject of the infobox.


See [[Imamatpedia:WikiProject Microformats]] for more information on adding microformat information to Imamatpedia, and [[microformat]] for more information on microformats in general.
See [[imamatpedia:WikiProject Microformats]] for more information on adding microformat information to imamatpedia, and [[microformat]] for more information on microformats in general.


== Examples ==
== Examples ==
Line 294: Line 349:
  |below      = Below text
  |below      = Below text
}}
}}
<source lang="Sass" style="overflow:auto" highlight="15">
<syntaxhighlight lang="Sass" style="overflow:auto" highlight="15">
{{Infobox
{{Infobox
  |name        = {{subst:PAGENAME}}
  |name        = {{subst:PAGENAME}}
Line 335: Line 390:
  |below      = Below text
  |below      = Below text
}}
}}
</source>{{clear}}
</syntaxhighlight>{{clear}}


For this example, the {{para|bodystyle}} and {{para|labelstyle}} parameters are used to adjust the infobox width and define a default width for the column of labels:
For this example, the {{para|bodystyle}} and {{para|labelstyle}} parameters are used to adjust the infobox width and define a default width for the column of labels:
Line 369: Line 424:
  |below = Below text
  |below = Below text
}}
}}
<source lang="sass" highlight="3,9" style="overflow: auto">
<syntaxhighlight lang="sass" highlight="3,9" style="overflow: auto">
{{Infobox
{{Infobox
  |name        = {{subst:PAGENAME}}
  |name        = {{subst:PAGENAME}}
Line 400: Line 455:
  |below = Below text
  |below = Below text
}}
}}
</source>{{clear}}
</syntaxhighlight>{{clear}}


== Embedding ==
== Embedding ==
<!--Linked from [[Template:Subinfobox bodystyle/doc]]-->
<!--Linked from [[Template:Subinfobox bodystyle/doc]]-->
One infobox template can be embedded into another using the {{para|child}} parameter or the {{para|embed}} parameter. This feature can be used to create a modular infobox, or to create better-defined logical sections. Long ago, it was necessary to use embedding in order to create infoboxes with more than 99 rows; but nowadays there's no limit to the number of rows that can be defined in a single instance of <code><nowiki>{{infobox}}</nowiki></code>.
One infobox template can be embedded into another using the {{para|child}} parameter. This feature can be used to create a modular infobox, or to create better-defined logical sections. Long ago, it was necessary to use embedding in order to create infoboxes with more than 99 rows; but nowadays there's no limit to the number of rows that can be defined in a single instance of <code><nowiki>{{infobox}}</nowiki></code>.


{{Infobox
{{Infobox
Line 509: Line 564:
</pre>{{clear}}
</pre>{{clear}}


Note that omitting the {{para|title}} parameter, and not including any text preceding the embedded infobox, may result in spurious blank table rows, creating gaps in the visual presentation.
Note that omitting the {{para|title}} parameter, and not including any text preceding the embedded infobox, may result in spurious blank table rows, creating gaps in the visual presentation. The garbage output can be suppressed using {{para|rowstyleN|display: none}}, replacing N with the data/header number.


[[Imamatpedia:WikiProject Infoboxes/embed]] includes some links to Imamatpedia articles which include infoboxes embedded within other infoboxes.
[[imamatpedia:WikiProject Infoboxes/embed]] includes some links to imamatpedia articles which include infoboxes embedded within other infoboxes.


== Subboxes ==
== Subboxes ==
Line 535: Line 590:
  | header6 = Main 6
  | header6 = Main 6
}}
}}
<source lang="sass" style="overflow:auto">
<syntaxhighlight lang="sass" style="overflow:auto">
{{Infobox
{{Infobox
  | headerstyle = background-color:#eee;
  | headerstyle = background-color:#eee;
Line 555: Line 610:
  | header6 = Main 6
  | header6 = Main 6
}}
}}
</source>{{clear}}
</syntaxhighlight>{{clear}}


Similar embedding techniques may be used within content parameters of some other templates generating tables (such as [[:Template:Sidebar|Sidebar]]) :
Similar embedding techniques may be used within content parameters of some other templates generating tables (such as [[:Template:Sidebar|Sidebar]]) :
Line 577: Line 632:
  | heading5 = Heading 5
  | heading5 = Heading 5
}}
}}
<source lang="sass" style="overflow:auto">
<syntaxhighlight lang="sass" style="overflow:auto">
{{Sidebar
{{Sidebar
  | navbar = off
  | navbar = off
Line 596: Line 651:
  | heading5 = Heading 5
  | heading5 = Heading 5
}}
}}
</source>{{clear}}
</syntaxhighlight>{{clear}}


Note that the default padding of the parent data cell containing each subbox is still visible, so the subboxes are slightly narrower than the parent box and there's a higher vertical spacing between standard cells of the parent box than between cells of distinct subboxes.
Note that the default padding of the parent data cell containing each subbox is still visible, so the subboxes are slightly narrower than the parent box and there's a higher vertical spacing between standard cells of the parent box than between cells of distinct subboxes.
Line 612: Line 667:
| subbox        = {{{subbox|}}}
| subbox        = {{{subbox|}}}
| italic title  = {{{italic title|no}}}
| italic title  = {{{italic title|no}}}
| templatestyles =
| child templatestyles =
| grandchild templatestyles =
| bodystyle      =  
| bodystyle      =  


Line 699: Line 757:


== Porting to other MediaWikis ==
== Porting to other MediaWikis ==
The infobox template requires the [[:mw:Extension:Scribunto|Scribunto]] extension and [[mw:Manual:Using content from Imamatpedia#HTMLTidy|HTMLTidy]] to be installed. It may not work with other MediaWikis. [[Imamatpedia:WikiProject Transwiki|WikiProject Transwiki]] has a version of this template that has been modified to work on other MediaWikis.
The infobox template requires the [[:mw:Extension:Scribunto|Scribunto]] extension. [[imamatpedia:WikiProject Transwiki|WikiProject Transwiki]] has a version of this template that has been modified to work on other MediaWikis.
 
== TemplateData ==
{{TemplateData header}}
<templatedata>
{
    "description": "This template is intended as a meta template, a template used for constructing other templates. In general, it is not meant for use directly in an article but can be used on a one-off basis if required.",
"format": "{{_\n| ________________ = _\n}}\n",
"params": {
"title": {
"label": "Title",
"description": "Title displayed above the infobox",
"type": "string",
"suggested": true
}
},
"paramOrder": [
"title"
]
}
</templatedata>
 
 
==Tracking categories==
* {{Category link with count|Articles with missing Wikidata information}}
* {{Category link with count|Articles using infobox templates with no data rows}}
* {{Category link with count|Pages using embedded infobox templates with the title parameter}}


==See also==
==See also==
* [[Module:Infobox]], the [[WP:LUA|Lua]] module on which this template is based
* [[Module:Infobox]], the [[WP:LUA|Lua]] module on which this template is based
* [[Special:Permalink/558855956|Template:Infobox/old]], the previous ParserFunctions implementation
* [[Module:Check for unknown parameters]]
* [[Module:Check for unknown parameters]]
* {{tl|Infobox3cols}}
* {{tl|Infobox3cols}}
* {{tl|Navbox}} and {{tl|Sidebar}}
* {{tl|Navbox}} and {{tl|Sidebar}}
* [[Imamatpedia:List of infoboxes|List of infoboxes]]
* [[imamatpedia:List of infoboxes|List of infoboxes]]
* [[:Module:InfoboxImage]]
* [[:Module:InfoboxImage]]
* Maintenance categories:
 
** [[:Category:Articles which use infobox templates with no data rows]] ({{PAGESINCATEGORY:Articles which use infobox templates with no data rows|pages}})
<includeonly>{{Sandbox other||
** [[:Category:Pages which use embedded infobox templates with the title parameter]] ({{PAGESINCATEGORY:Pages which use embedded infobox templates with the title parameter|pages}})
<includeonly>{{#ifeq:{{SUBPAGENAME}}|sandbox | |
[[Category:Infobox templates| ]]
[[Category:Infobox templates| ]]
[[Category:Imamatpedia metatemplates|Infobox]]
[[Category:imamatpedia metatemplates|Infobox]]
[[Category:Templates generating microformats]]
[[Category:Templates generating microformats]]
[[Category:Lua-based infobox templates]]
[[Category:Templates that add a tracking category]]
[[Category:Templates based on the Infobox Lua module]]
}}</includeonly>
}}</includeonly>
==Tracking categories==
* {{clc|Articles with missing Wikidata information}}
Anonymous user