Out of Ore Wiki:DPL Tricks: Difference between revisions
No edit summary |
No edit summary |
||
| Line 54: | Line 54: | ||
* [[Template:OOO date]] — helper template used for formatting | * [[Template:OOO date]] — helper template used for formatting | ||
* [[Template:Version infobox]] — where the raw <code>date</code> param is defined | * [[Template:Version infobox]] — where the raw <code>date</code> param is defined | ||
* [[Category:Version History]] — page using the DPL output | * [[:Category:Version History]] — page using the DPL output | ||
* [https://www.mediawiki.org/wiki/Extension:DynamicPageList3 DynamicPageList3 documentation on mediawiki.org] | * [https://www.mediawiki.org/wiki/Extension:DynamicPageList3 DynamicPageList3 documentation on mediawiki.org] | ||
Feel free to expand this page with other useful DPL tricks or parser-related workarounds! | Feel free to expand this page with other useful DPL tricks or parser-related workarounds! | ||
Latest revision as of 23:34, 1 December 2025
DPL3 Date Formatting in Tables
When using DynamicPageList3 (DPL3) to build version history or changelog tables, you may run into issues where the date values appear unformatted, even when using a helper template like {{OOO date}} that works elsewhere.
This page documents the root cause and solution.
Problem
DPL3 inserts data (like %% placeholders) after MediaWiki's parser has already run. So if you try this in a tablerow:
| tablerow = [[%PAGE%|%%]], {{OOO date|%%}}, %% , %%
…the template {{OOO date|%%}} is not parsed as a real template call. It just outputs as literal text, or sometimes breaks the row entirely.
Solution
Use DPL’s delayed evaluation syntax:
| tablerow = [[%PAGE%|%%]], ²{OOO date¦%%}², %% , %%
Explanation:
²{and}²(superscript 2) tell DPL to defer the parsing of the template call.¦(section divider character) replaces the normal|pipe so DPL doesn't misinterpret it as a column split.- The result is equivalent to {{OOO date|2023-12-03}} at render time — and the date displays correctly as, for example, "December 3, 2023".
Example
If you're using an infobox like Template:Version infobox with a date field, and you want that formatted in your auto-generated table using the parser function form of DPL:
{{#dpl:
| category = Updates
| namespace = Main
| ordermethod = sortkey
| order = descending
| include = {Version infobox}:version:date:type:summary
| table = class="wikitable sortable",-,Version,Date,Type,Summary
| tablerow = [[%PAGE%|%%]], ²{OOO date¦%%}², %% , %%
}}
This ensures every row uses the same readable date format consistently.
Notes
- The Template:OOO date template should handle fallback and formatting via #time safely.
- This technique works with both {{#dpl:}} and (in theory) <dpl> tag usage, though this example uses the parser function form.
- The
²{...}²technique is also useful for wrapping #arraymap, #iferror, or even #invoke calls inside DPL output.
See Also
- Template:OOO date — helper template used for formatting
- Template:Version infobox — where the raw
dateparam is defined - Category:Version History — page using the DPL output
- DynamicPageList3 documentation on mediawiki.org
Feel free to expand this page with other useful DPL tricks or parser-related workarounds!