Out of Ore Wiki:DPL Tricks: Difference between revisions
Created page with "== DPL3 Date Formatting in Tables == When using [[https://www.mediawiki.org/wiki/Extension](https://www.mediawiki.org/wiki/Extension):DynamicPageList3 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 <nowiki>{{OOO date}}</nowiki> that works elsewhere. This page documents the root cause and solution. === Problem === DPL3 inserts data (lik..." |
No edit summary |
||
| Line 1: | Line 1: | ||
== DPL3 Date Formatting in Tables == | == DPL3 Date Formatting in Tables == | ||
When using [[ | When using [[mw:Extension:DynamicPageList3|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 <nowiki>{{OOO date}}</nowiki> that works elsewhere. | ||
This page documents the root cause and solution. | This page documents the root cause and solution. | ||
| Line 12: | Line 12: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
…the template <nowiki>{{OOO date|%%}}</nowiki> is not parsed as a real template call. It just outputs as literal text, or sometimes breaks the row entirely. | |||
=== Solution === | === Solution === | ||
| Line 23: | Line 23: | ||
'''Explanation:''' | '''Explanation:''' | ||
* <code>²{</code> and <code>}²</code> (superscript 2) | * <code>²{</code> and <code>}²</code> (superscript 2) tell DPL to defer the parsing of the template call. | ||
* <code>¦</code> (section divider character) replaces the normal <code>|</code> pipe so DPL doesn't misinterpret it as a column split. | * <code>¦</code> (section divider character) replaces the normal <code>|</code> pipe so DPL doesn't misinterpret it as a column split. | ||
* The result is equivalent to <nowiki>{{OOO date|2023-12-03}}</nowiki> at render time — and the date displays correctly as, for example, "December 3, 2023". | * The result is equivalent to <nowiki>{{OOO date|2023-12-03}}</nowiki> at render time — and the date displays correctly as, for example, "December 3, 2023". | ||
| Line 47: | Line 47: | ||
* The [[Template:OOO date]] template should handle fallback and formatting via <nowiki>#time</nowiki> safely. | * The [[Template:OOO date]] template should handle fallback and formatting via <nowiki>#time</nowiki> safely. | ||
* This technique works with both <nowiki>{{#dpl:}}</nowiki> and (in theory) <nowiki> | * This technique works with both <nowiki>{{#dpl:}}</nowiki> and (in theory) <nowiki><dpl></nowiki> tag usage, though this example uses the parser function form. | ||
* The <code>²{...}²</code> technique is also useful for wrapping <nowiki>#arraymap</nowiki>, <nowiki>#iferror</nowiki>, or even <nowiki>#invoke</nowiki> calls inside DPL output. | * The <code>²{...}²</code> technique is also useful for wrapping <nowiki>#arraymap</nowiki>, <nowiki>#iferror</nowiki>, or even <nowiki>#invoke</nowiki> calls inside DPL output. | ||
| Line 55: | Line 55: | ||
* [[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] | ||
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! | ||
Revision as of 23:31, 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 - — 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!