Examples/Parameter: include (example 4)
Example
[edit source]This lists pages in category Fruit examples and uses include to include from the Fruit-Infobox template, the variable for page title (%TITLE%), and the "image" and "grows" parameter values. In the table statement, the first argument adds CSS classes to the table, the second "-" deliberately omits the (automatic) linked page name from the first column, and the rest specify column headings.
The tablerow parameter essentially allows the values it holds to be precisely positioned within any formatting applied; the %TITLE% (first) value of the include is carried down to the first column by specifying %% in first position of the tablerow statement. The title is then wrapped in a <span></span> with formatting to make it italic. The next argument carried down is the "image" value (using %%) adding content before and after to format it as a rendered image at 30 pixels wide. The last tablerow argument %% displays the results of the "grows" parameter, this time without added formatting.
Important notes:
- The
includeandtablerowparameters work together as a pair (tablealso). - The
tablerowparameter essentially allows values to be precisely positioned within any basic formatting it applies. - Using
%%caries down each value from theincludestatement, to the same position in thetablerowstatement, though this is affected by the automatic creation of a first column containing linked page name (which we've used-in second position of thetablestatement to suppress).
- Code
{{#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
| Page Name | Image | Grows |
|---|---|---|
| Apple | On trees | |
| Grape | On vines | |
| Orange | On trees | |
| Plum | ||
| Banana | On a tree-like plant |