Examples/Parameter: format (example 2): Difference between revisions

From DynamicPageList3 Manual
Content added Content deleted
imported>FrozenPlum
m (Refine the statement explaining the example)
imported>FrozenPlum
m (Can’t leave this with the depreciated syntax, but it no longer makes sense with DPL tag syntax either and needs proper font sizing method, I have to make it make sense using #expr, but I was planning on swapping most things to parser function syntax anyhow, since it is most advantageous (and less problematic for uses to learn first and simplify to tag later if desired, where the other way round is more problematic to learn))
Line 6: Line 6:
==Example==
==Example==


The following is an example of how to use the {{DPL|variables|variable}} {{code|%NR%}} to set the font size. This will list articles in [[:Category:Fruit examples]], by title (in descending order), limited to a count of four. Each result will be formatted to appear on a new line and the font size will be set to the current article sequence number (starting from 1).
The following is an example of how to use the {{DPL|variables|variable}} {{code|%NR%}} to set the font size. This will list articles in [[:Category:Fruit examples]], by title (in descending order), limited to a count of four. Each result will be formatted to appear on a new line and the font size will be set using a [[mw:Help:Extension:ParserFunctions##expr|parser function (math) expression]], to a calculate the current article sequence number (starting from 1) times 0.5em, which will increase the font size each subsequent article.


<pre>
<pre>
<dpl>
{{#dpl:
category = Fruit examples
|category = Fruit examples
|count = 3
ordermethod = title
|ordermethod = title
order = descending
count = 4
|order = descending
format = ,\n<font size="%NR%">'''[[%PAGE%]]'''</font>,<br/>,
|format = ,\n<span style="font-size: ²{#expr:%NR% * 0.5}²em;">'''[[%PAGE%]]'''</span>,\n,
</dpl>
}}</pre>

</pre>


==Result==
==Result==


<dpl>
{{#dpl:
category = Fruit examples
|category = Fruit examples
count = 4
|count = 3
ordermethod = title
|ordermethod = title
order = descending
|order = descending
format = ,\n<font size="%NR%">'''[[%PAGE%]]'''</font>,<br/>,
|format = ,\n<span style="font-size: ²{#expr:%NR% * 0.5}²em;">'''[[%PAGE%]]'''</span>,\n,
}}
</dpl>


<noinclude>
<noinclude>
Line 34: Line 34:
[[Category:Uses count parameter]]
[[Category:Uses count parameter]]
[[Category:Uses format parameter]]
[[Category:Uses format parameter]]
[[Category:Uses ParserFunctions]]
</noinclude>
</noinclude>

Revision as of 09:37, 17 April 2022

Please do not edit this page unless you're wanting to edit the manual itself, it is an example included in the manual.

Example

The following is an example of how to use the variable %NR% to set the font size. This will list articles in Category:Fruit examples, by title (in descending order), limited to a count of four. Each result will be formatted to appear on a new line and the font size will be set using a parser function (math) expression, to a calculate the current article sequence number (starting from 1) times 0.5em, which will increase the font size each subsequent article.

{{#dpl:
|category	 = Fruit examples
|count		 = 3
|ordermethod	 = title
|order		 = descending
|format	 = ,\n<span style="font-size: ²{#expr:%NR% * 0.5}²em;">'''[[%PAGE%]]'''</span>,\n,
}}


Result

{{#dpl: |category = Fruit examples |count = 3 |ordermethod = title |order = descending |format = ,\n%PAGE%,\n, }}