Examples/Parameter: include (example 4): Difference between revisions

From DynamicPageList3 Manual
Content added Content deleted
imported>FrozenPlum
(This was a tough one to refine and explain, because it's a technicality that needs explaining. Hard to do that in a simple, straight-forward way.)
 
imported>FrozenPlum
m (FrozenPlum moved page Controlling output volume/Parameter: include (example 4) to Examples/Parameter: include (example 4): Simplifying how things are structured)
 
(3 intermediate revisions by the same user not shown)
Line 9:
 
 
'''Note:''' Since the last column value does not have formatting applied, the comma before it and its value (<code>,%%</code>) could ''technically'' be left off (specifying an empty <code>,</code> suppresses the value from displaying). TheWithout the comma, the column's value would still appear because by default <code>include</code> automatically adds values as-is to the output, (<code>tablerow</code> just allows precise positioning of values ''inside formatting,its correspondingcolumn's toformatting''. the same column); thoughHowever, to includeadd andmore formatvalues ''more values after that'' one, values must still align 1:1 with the include position. Specifying an empty <code>{{DPL|tablerow}}</code> would suppress that column's value from displaying at all (which would be undesired) so that column's value wouldthen '''have to''' be specified, simply to hold its position inwithin the 1:1comma mapingseparated with <code>include</code>list. For this reason, it is generally bestgood practice to map values 1:1 fromwith <code>includetablerow</code> to put all values from an <code>tablerowinclude</code> wheneverstatement into the corresponding position of <code>tablerow</code> is used, thisit can helps avoid confusion if/whenon otherlater columnsedits need toand/or be added lateradditions.
 
<pre>
Line 16:
|include = {Fruit-Infobox}:%TITLE%:image:grows
|table = class="wikitable sortable",-,Page Name, Image, Grows
|tablerow = <i>%%</i>,[[File:%%|30px]],%%
|tablerow = <span style="font-style: italic;">%%</span>,[[File:%%|30px]],%%
|count = 5
Line 32 ⟶ 31:
}}
<noinclude>
[[Category:ControllingInclude outputcontents volumefrom (examples)‎the articles in the result set‎]]
[[Category:Uses category parameter]]
[[Category:Uses include parameter]]

Latest revision as of 01:13, 1 April 2023

Please do not edit this page unless you're wanting to edit the manual itself, it is an example included in the manual.

Example

This example selects articles in Category:Fruit examples and uses include to include the DPL variable for page title, the "image" parameter value, and the "grows" parameter value. The first argument of the table statement adds classes to the table, the second omits the (automatic) linked page name first column (using -, so the page name can be manually inserted without a link and formatted), and the rest of the arguments create the remaining page headers. The tablerow parameter allows the values to be precisely positioned within the formatting applied; the %TITLE% first column is given inside <i></i> (italic) formatting, followed by the "image" value formatted as a rendered image at 30 pixels wide, and then the "grows" parameter value displayed last.


Note: Since the last column value does not have formatting applied, the comma before it and its value ,%% could technically be left off (specifying an empty , suppresses the value from displaying). Without the comma, the column value would still appear because include automatically adds values as-is to the output, tablerow just allows precise positioning of values inside its column's formatting. However, to add more values after that one, that column's value would then have to be specified, simply to hold its position within the comma separated list. For this reason, it is generally good practice with tablerow to put all values from an include statement into the corresponding position of tablerow, it can helps avoid confusion on later edits and/or additions.

{{#dpl:
|category      = Fruit examples
|include       = {Fruit-Infobox}:%TITLE%:image:grows
|table         = class="wikitable sortable",-,Page Name, Image, Grows
|tablerow      = <span style="font-style: italic;">%%</span>,[[File:%%|30px]],%% 
|count         = 5
}}

Result

{{#dpl: |category = Fruit examples |include = {Fruit-Infobox}:%TITLE%:image:grows |table = class="wikitable sortable",-,Page Name, Image, Grows |tablerow = %%,File:%%,%% |count = 5 }}