Generating tabular output (examples): Difference between revisions

m
transclude back to here
imported>FrozenPlum
m (FrozenPlum moved page Test table to Generating tabular output (examples) without leaving a redirect)
imported>FrozenPlum
m (transclude back to here)
Line 164:
'''Notes:'''
* <code>%%</code> values can be reused '''in the same column'''.
* Since <code>%%</code> essentially "caries"allows the correspondingvalues 1:1of a column valuesto be positioned precisely within whatever formatting is to be applied; otherwise, it simply carries the value down from the corresponding <code>include</code> statementcolumn to applyits formattingcell, if other formatted values need to appear in columns after it. Given values correspond to the <code>include</code> position, they can't be reusedmoved '''inor ''other''used between columns''' in a {{DPL|tablerow}} statement, without the use of {{DPL|#dplvar}} to move the values between columns (though a surrogate templatetemplates can better enableachieve movingthis columnsame goal, allowing values to otherbe columnsused inanywhere within the sameoutput resultthey rowformat).
* '''Templates used multiple times''' on a page, have their values automatically grouped and listed under the same page line (the [[Apple]] page uses the "<code><nowiki>{{Color}}</nowiki></code>" template twice, so two color names appear), since these are grouped under the same page result, the color value <code>%%</code> can only be used to set the style for text color once, which is why the "green" value is red and not green.
* If you need the contents of templates reused on the same page to be displayed on separate lines, see the {{DPL|multisecseparators}} example of how this is done instead of <code>tablerow</code> (by using a combination of <code>include</code>, <code>listseparators</code>, <code>secseparators</code>, and <code>multisecseparators</code> instead.
Line 181:
== Using a surrogate template ==
 
'''Example:'''<br><br><!-- transclude example from subpage-->{{#lsth:Controlling output format/Parameter:_table_(example 3)|Example}}
This example uses a surrogate (also known as a phantom) template to specify and/or format a single row of results, using [[mw:Help:Templates#Parameters|named]] <code><nowiki>{{{grows|}}}</nowiki></code> or <code><nowiki>{{{1|}}}</nowiki></code> [[mw:Help:Templates#Parameters|numbered]] parameters. See the source code of [[Template:Fruit-Infobox.templatevalues‎‎]].
{{example|table|base=Controlling output format|eg=3}}
 
'''Result:'''<br><!-- transclude result from subpage-->{{#lsth:Controlling output format/Parameter:_table_(example 3)|Result}}
 
See== {{DPL|include}}Using for more information on''multiple'' surrogate templates. ==
 
Multiple surrogates might be used only if you need to access parameter values from '''different templates''' used on the set of pages; otherwise, it is generally better to use just one.
 
This selects pages in [[:Category:Fruit examples]], in the <code>table</code> statement, the styles are set in the first position, then the first column's name is set as "Page". Remember, the first column is automatically generated by DPL3 in <code>table</code> statements (and can't be formatted unless omitted with <code>-</code> taking the position of the "Page" table header and then added to the surrogate instead. first column of table output (linked page name) is automatically generated unless intentionally omitted with <code>-</code> after settings includes uses two surrogate (also known as a phantom) templates to specify and/or format a single row of results using [[mw:Help:Templates#Parameters|named]] <code><nowiki>{{{grows|}}}</nowiki></code> or [[mw:Help:Templates#Parameters|numbered]] <code><nowiki>{{{1|}}}</nowiki></code> parameters. See the source code of [[Template:Fruit-Infobox.templatevalues‎‎]] and [[Template:Color.templatevalues‎‎]]. Since a surrogate template is used to format the output of the "Color" tem
'''Example:'''<br>
<pre>
{{#dpl:
|category = Fruit examples
|include = {Fruit-Infobox}.templatevalues
|table = ,Page,Grows,Image
|count = 5
}}
</pre>
 
 
'''Result:'''<br>
{{#dpl:
|category = Fruit examples
|include = {Fruit-Infobox}.templatevalues
|table = ,Page,Grows,Image
|count = 5
}}
 
 
== Using ''multiple'' surrogate templates ==
 
'''ResultNotes:'''<br>
This example uses two surrogate (also known as a phantom) templates to specify and/or format a single row of results, using [[mw:Help:Templates#Parameters|named]] <code><nowiki>{{{grows|}}}</nowiki></code> or <code><nowiki>{{{1|}}}</nowiki></code> [[mw:Help:Templates#Parameters|numbered]] parameters. See the source code of [[Template:Fruit-Infobox.templatevalues‎‎]] and [[Template:Color.templatevalues‎‎]].
* <code><nowiki>{{{%PAGE%}}}</nowiki></code> can be used to access page name (with namespace) in a surrogate template.
* <code><nowiki>{{{%TITLE%}}}</nowiki></code> can be used to access page name (without namespace) in a surrogate template.
 
 
Line 219 ⟶ 204:
{{#dpl:
|category = Fruit examples
|table = class="wikitable sortable",Page,Grows,Image,Color
|include = {Fruit-Infobox}.templatevalues,{Color}.templatevalues
|table = ,Page,Fruit-Infobox<br><code>color=</code>,Fruit-Infobox<br><code>image=</code>,Color<br>(unnamed parameter whose value is specified <code>1</code>
|count = 5
}}
Line 229 ⟶ 214:
{{#dpl:
|category = Fruit examples
|table = class="wikitable sortable",Page,Grows,Image,Color
|include = {Fruit-Infobox}.templatevalues,{Color}.templatevalues
|table = ,Page,Fruit-Infobox<br><code>color=</code>,Fruit-Infobox<br><code>image=</code>,Color<br>(unnamed parameter whose value is specified <code>1</code>
|count = 5
}}
Line 268 ⟶ 253:
 
== Get 2 section's contents ==
This example includes article's "Notes" and "More" page section contents, for pages in [[:Category:Fruit examples]] that have these sections. The "More" section content is limited to 15 characters <code><nowiki>#More[15]</nowiki></code>. The <code>tablerow</code> statement has <code>%%</code> for each value that needsallow tofor beprecise carriedpositioning downof toits contents in applied formatting (if any) or simply display the itsvalue if correspondingno tableformatting rowis cellneeded. The second is section is formatted in italics, the output count also limited to 3 results.
 
 
Anonymous user