Generating tabular output (examples): Difference between revisions
Content added Content deleted
imported>FrozenPlum m (Fix title level) |
imported>FrozenPlum No edit summary |
||
Line 9: | Line 9: | ||
=== Single template value=== |
=== Single template value=== |
||
This selects articles in [[:Category:Fruit examples]] whose article names are automatically generated and placed in the first column (unless chosen to be omitted). It then includes the "Fruit-Infobox" template "grows" parameter value, for each article in the result set, in the second column. The <code>table=</code> statement sets the table styles (if desired) before the first comma, and then sets the header column text. The <code>tablerow=</code> statement can be used to format some or all of the output, '''but starting after''' the page name, so '''it corresponds to the second column'''so it colors the second column green; <code>%%</code> is used to position the value after the formatting. The results are limited to a count of 5. |
|||
'''Example:'''<br><br><!-- transclude example from subpage-->{{#lsth:Controlling output format/Parameter:_tablerow_(example 1)|Example}} |
|||
{{example|tablerow|eg=1}} |
|||
'''Result:'''<br><!-- transclude result from subpage-->{{#lsth:Controlling output format/Parameter:_tablerow_(example 1)|Result}} |
|||
⚫ | |||
⚫ | |||
'''Example:'''<br> |
|||
<!-- The <code>{{DPL|tablerow}}</code> statement is best explained by an example: |
|||
<pre> |
<pre> |
||
<dpl> |
|||
category=Help |
|||
|category = Fruit examples |
|||
titlematch=DPL% |
|||
|include = {Fruit-Infobox}:grows |
|||
count=4 |
|||
|table = class="wikitable sortable",Page,The first parameter<br>of the Template Call |
|||
includepage ={DPL Manual}:section,%-1[25] |
|||
⚫ | |||
table =,Title,Sub Title,Last Section (25 chars) |
|||
|count = 5 |
|||
⚫ | |||
}} |
|||
</dpl> |
|||
</pre> |
</pre> |
||
<dpl> |
|||
category=Help |
|||
titlematch=DPL% |
|||
count=4 |
|||
includepage ={DPL Manual}:section,%-1[25] |
|||
table =,Title,Sub Title,Last Section (25 chars) |
|||
⚫ | |||
</dpl> |
|||
The following example includes the use of {{DPL|addpagecounter}} and {{tt|%COUNT%}}, both of which were removed in MediaWiki 1.25. |
|||
<pre> |
|||
'''Result:'''<br> |
|||
<dpl> |
|||
category=African Union member states |
|||
|category = Fruit examples |
|||
nottitlematch=Sudan |
|||
|include = {Fruit-Infobox}:grows |
|||
addpagecounter=true |
|||
|table = class="wikitable sortable",Page,The first parameter<br>of the Template Call |
|||
includepage ={Infobox Country or territory}:area:population_estimate,%0[100] |
|||
⚫ | |||
format =,,\n|style="text-align:right;"|²{#ifexpr:%COUNT%>300¦<big>'''%COUNT%'''</big>¦%COUNT%}², |
|||
|count = 5 |
|||
table =,Country,Area,Population,Text,#hits |
|||
}} |
|||
tablerow =style="text-align:right;"|%%,style="text-align:right;"|%%,style="background-color:lightyellow;"|<small>%%</small>,\n|style="text-align:right;"|%% |
|||
</dpl> |
|||
</pre> |
|||
* We select some African countries, we exclude Sudan |
|||
* We acquire a piece of meta data about the articles we will find (in our case the usage counter) |
|||
* We include two named parameters from a template call, <nowiki>{{Infobox Country or territory}}</nowiki> |
|||
* We include a short text passage from the text before the first chapter |
|||
* We use the third parameter of <code>{{DPL|format}}</code> to output the usage counter (we could even highlight values above 100 here, for example) |
|||
* We highlight usage values above 300 |
|||
* We define a standard wiki table with the article name in the first column (named "Country") |
|||
* We define column headers for transcluded contents and for the usage counter |
|||
* We care for right alignment of the numerical values and define a background-color for the text --> |
|||