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 |
||
| (One intermediate revision by the same user not shown) | |||
| 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 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] | ||
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! | ||