Examples/Parameter: include (example 4)

From DynamicPageList3 Manual
Revision as of 02:00, 20 April 2022 by 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.)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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 value does not have formatting applied, the comma before it and its value (,%%) could technically be left off. The column's value would still appear because by default include automatically adds values as-is to the output (tablerow just allows precise positioning of values inside formatting, corresponding to the same column); though to include and format more values after that, values must still align 1:1 with the include position. Specifying an empty tablerow would suppress that column's value from displaying at all (which would be undesired) so that column's value would have to be specified simply to hold its position in the 1:1 maping with include. For this reason, it is generally best practice to map values 1:1 from include to tablerow whenever tablerow is used, this helps avoid confusion if/when other columns need to be added later.

{{#dpl:
|category      = Fruit examples
|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
}}

Result

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