Anonymous user
Generating tabular output (examples): Difference between revisions
Add example for a (hopefully) good transition in the learning
imported>FrozenPlum m (update the name of this example, since I swapped them) |
imported>FrozenPlum (Add example for a (hopefully) good transition in the learning) |
||
(5 intermediate revisions by the same user not shown) | |||
Line 1:
{{DPL manual|section=Examples|subsection=Generating tabular output}}
{{tocright}}
Line 9 ⟶ 8:
=== Single template value===
'''Example:'''<br><br><!-- transclude example from subpage-->{{#lsth:Examples/Parameter: tablerow (example 1)|Example}}
{{example|tablerow|base=Controlling output format|eg=1}}
'''Result:'''<br><!-- transclude result from subpage-->{{#lsth:Examples/Parameter: tablerow (example 1)|Result}}
'''Note:''' The <code>%%</code> in <code>tablerow</code> allows precise positioning of the column value, inside whatever formatting you want to apply.▼
▲'''Note:''' The <code>%%</code> in <code>tablerow</code> allows precise positioning of the column value, inside whatever formatting you want to apply.
'''Example:'''<br>▼
<!-- The <code>{{DPL|tablerow}}</code> statement is best explained by an example:
<pre>
category=Help
titlematch=DPL%
count=4
includepage ={DPL Manual}:section,%-1[25]
|tablerow = style="background:#eeffee;"¦%%▼
table =,Title,Sub Title,Last Section (25 chars)
</dpl>
</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>
category=African Union member states
nottitlematch=Sudan
addpagecounter=true
includepage ={Infobox Country or territory}:area:population_estimate,%0[100]
▲|tablerow = style="background:#eeffee;"¦%%
format =,,\n|style="text-align:right;"|²{#ifexpr:%COUNT%>300¦<big>'''%COUNT%'''</big>¦%COUNT%}²,
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 -->
Line 129 ⟶ 151:
'''Example:'''<br><br><!-- transclude example from subpage-->{{#lsth:
{{example|include|base=Controlling output volume|eg=4}}
'''Result:'''<br><!-- transclude result from subpage-->{{#lsth:
===#dplvar to move/duplicate parameters between columns===
{{#lsth:Examples/Parameter: tablerow (example 2)|Example}}
{{ViewTest|Examples|Parameter: tablerow (example 2)}}
'''Result:'''<br><!-- transclude result from subpage-->
{{#lsth:Examples/Parameter: tablerow (example 2)|Result}}
Line 265 ⟶ 297:
===Single surrogate template===
'''Example:'''<br><br><!-- transclude example from subpage-->{{#lsth:
{{example|table|base=Controlling output format|eg=3}}
'''Result:'''<br><!-- transclude result from subpage-->{{#lsth:
===Multiple surrogate templates===
Multiple surrogates might be used only if you need to access parameter values from '''different templates''' used on the same page or set of pages; otherwise, it is generally better to use just one.
|