Examples/Module: dplmatrix (example 3)

From DynamicPageList3 Manual
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 uses the #dplmatrix module to create a matrix, whose first parameter (matrix name) is set to "Dessert examples linking to Fruit examples". The second parameter is set to '''x''' (specifies a bold "x" as the symbol for indicating a link), the third is set to - (as the symbol for indicating no link), and the fourth is set to flip (the matrix layout mode), which flips normal column position to rows instead.


The fifth parameter specifies the indented list contents, in this case it is a DPL3 statement which sets Category:Dessert examples as the link source. Since the mode is flipped, the dessert examples appear in column headers. The DPL3 statement uses the format parameter to format the page title of each of the source links. Directly thereafter, the Template:Test matrix2 is called, and the format statement passes to that template the page value of %PAGE%, and the category value of Fruit examples, which are used to create the nested part of the list (explained in examples below).

{{#dplmatrix:Dessert examples linking to Fruit examples|'''x'''|-|flip|
  {{#dpl:
    |category=Dessert examples
    |count=5
    |format=,%PAGE% ~~ %TITLE%\n²{Test matrix2¦page=%PAGE%¦category=Fruit examples}²,
  }}
}}

Result

{{#dplmatrix:Dessert examples linking to Fruit examples|x|-|flip|

 {{#dpl:
   |category=Dessert examples
   |count=5
   |format=,%PAGE% ~~ %TITLE%\n²{Test matrix2¦page=%PAGE%¦category=Fruit examples}²,
 }}

}}

As can be observed by visiting their pages, the Apple Pie article links to the Apple article, the Chocolate Cake article links to the Plum article, and the Raspberry Ice Cream article links to both of the other two articles.

Notes

To better understand what is occurring in the DPL3 statement, and how it forms the required "indented list" format, it's best to remove it from the {{#dplmatrix:}}, so its output can be viewed alone. This makes visible how the DPL3 statement creates the first level (non-indented) part of the list, and calls a template to create the second level.


Example:

{{#dpl:
    |category=Dessert examples
    |count=5
    |format=,%PAGE% ~~ %TITLE%\n²{Test matrix2¦page=%PAGE%¦category=Fruit examples}²,
}}


Result:

{{#dpl:

   |category=Dessert examples
   |count=5
   |format=,%PAGE% ~~ %TITLE%\n²{Test matrix2¦page=%PAGE%¦category=Fruit examples}²,

}}


Template content

Lastly, to understand the Test matrix2 template (which is a second DPL3 statement), and how it accepts the values passed to it earlier, and formats the indented part of the list, it is best to view its contents as well:

Template:Test matrix2 content:

This example sets the namespace to [blank] (the "Main" namespace), sets the category to "Fruit examples" as was passed from the other DPL3 statement, and sets the linksfrom value to %PAGE% as was also passed from that statement. The count is then restricted to five, and the format line creates spaces before the linked page title.

{{#dpl:
 |namespace=
 |category={{{category}}}
 |linksfrom={{{page}}}
 |count=5
 |format=,   %PAGE% ~~ %TITLE%\n,
}}