Please remember to make use of the Manual of Style and Code of Conduct during your stay.

 Actions

Help

Extension - DPL3/Table Example

From Dragon Mania Legends (DML) Wiki

< Help:Extension - DPL3
link=Category:{{{base}}} (Element)
The following page or feature is intended for use by DML Wiki Staff (Bureaucrats) who work with advanced MediaWiki Extension functionality.

Creating a formatted table in DPL3 can be a bit challenging, fortunately a step-by step approach (with examples) can make it much easier.

Table Output[edit]

An example of creating a DPL auto-table (only Bureaucrats should work with DPL3) is page name here page.

Select Pages[edit]

First we need to select the right pages to list in the output, so we start simple there.

Note: Notice the difference in syntax between the two different DPL use methods!

First we'll start with just displaying the list of items for output to see if we're getting the pages we expect.

  • Boss Dragons Icon.png Caution: Always intentionally limit the number of possible results you can get with count=5 to avoid an unintentional huge result set:

Code:
{{#dpl:
|category=Dragons
|notcategory=Clan Dragons
|notcategory=Boss Dragons
|count=5
}}

Result

First we'll start with just displaying the list of items for output to see if we're getting the pages we expect (intentionally limited via count=5 to avoid a huge result set):
Code:

<dpl>
  category=Dragons
  notcategory=Clan Dragons
  notcategory=Boss Dragons
  count=5
</dpl>

Result



OOPS! Nope, ↑ that (above) is not what we wanted, and why testing initial output before output is so important.
We wanted Dragons-only so we need a category that houses only Dragons (which Standard Dragons does):

First we'll start with just displaying the list of items for output to see if we're getting the pages we expect (intentionally limited via count=5 to avoid a huge result set):
Code:

{{#dpl:
|category=Standard Dragons
|notcategory=Clan Dragons
|notcategory=Boss Dragons
|count=5
}}

Result

First we'll start with just displaying the list of items for output to see if we're getting the pages we expect (intentionally limited via count=5 to avoid a huge result set):
Code:

<dpl>
  category=Standard Dragons
  notcategory=Clan Dragons
  notcategory=Boss Dragons
  count=5
</dpl>

Result

Include/Volume[edit]

Okay, so now that we're getting the pages listed in the output that we wanted/needed, lets include some template parameter values with it, we'll do page title, then cost. The "include" can be used to set parameter values to include in simple output (inline or table), separated by colons:

Simple List Include[edit]

By default the page name is already output into a simple list, so referencing the {template}:parameter will include a page's parameter value (or chain of them {template}:cost:base:second:third) followed by a comma. This lets us test that we're getting the parameter values from the template:
Code:

{{#dpl:
|category=Standard Dragons
|notcategory=Clan Dragons
|notcategory=Boss Dragons
|include = {DragonBox}:cost,
|count=5
}}


Result:

link=Category:{{{base}}} (Element)
The following page or feature is intended for use by DML Wiki Staff (Bureaucrats) who work with advanced MediaWiki Extension functionality.

Simple Table with Include[edit]

Okay, now that we're getting the output we want, we can look at formatting it into a table. Notice we have:

  • to set format
  • listseparators to start the table, set its header, and end the table.
  • secseparators customize the output format of included sections.
    • secseparators=Start1,End1,Start2,End2,..,..

{{#dpl:
|category = Uncommon (classification)
|notcategory = Clan Dragons
|notcategory = Boss Dragons
|include = {DragonBox}:[[%PAGE%|%TITLE%]]:cost,
|mode = userformat
|count=5
|listseparators = \n{¦class="wikitable sortable" \n¦-\n!Dragon \n!Cost ,\n¦-,\n¦-\n¦-,\n¦}
|secseparators  = \n¦class="orange-box"¦,,\n¦, 
}}


Result:

Dragon Cost
Armored Dragon 400
Assassin Dragon 8
Bee Dragon 325
Breeze Rock Dragon 299
Brick Dragon 425

Note: Formatting is very limited in this simple table mode, for advanced formatting use a surrogate template.

<dpl>
 category = Uncommon (classification)
 notcategory = Clan Dragons
 notcategory = Boss Dragons
 include = {DragonBox}:[[%PAGE%|%TITLE%]]:cost,
 mode = userformat
 count = 5
 listseparators = ¶{|class="wikitable sortable" ¶|-¶!Dragon ¶!Cost ,¶|-,¶|-¶|-,¶|}
 secseparators  = ¶|class="orange-box"|,,¶|, 
</dpl>


Result:

Dragon Cost
Armored Dragon 400
Assassin Dragon 8
Bee Dragon 325
Breeze Rock Dragon 299
Brick Dragon 425
Note: Formatting is very limited in this simple table mode, for advanced formatting use a surrogate template.

Table w/Surrogate Template to Calculate[edit]

BUT, a plain unformatted table doesn't exactly accomplish what we're after, and we can't put code in include statements, it won't work... so we can choose to instead use a surrogate template to format the content of the table.
Info coming soon

Surrogate templates are templates that "chain" off of the template used to create the results on pages in your list. So for Dragons, this template is {{DragonBox}}. I create a new template with a suffix that describes what it is for (in this case Dragon Cost Compairison) which results in: {{DragonBox.dragoncostcomparison}}. Now that template formats the body of each line in the table. So the table already has a start and end, plus | separators at the very start and very end of each line. It's the content in-between that the surrogate template governs, and what it's content should prescribe, the lines that create the middle of the table (and can include parser functions, DPL variables, other templates etc.

  • includepage={TemplateName}.suffix calls the template and tells DPL to use it to format each line.
  • The contents of the surrogate should only be for 1 line, DPL will apply it repeatedly to the rest.
  • Use DPL variables to retrieve information, and use {{{cost}}} parameters.
  • User parser functions to calculate stuff as usual.


Code:

{{#dpl:
|category=Standard Dragons
|notcategory=Clan Dragons
|notcategory=Boss Dragons
|count=20
|includepage={DragonBox}.dragoncostcomparison
|allowcachedresults = true
|mode  = userformat
|listseparators    = ¶{¦class="wikitable sortable" ¶¦-¶!Event ¶!Type ,¶¦-,¶¦-¶¦-,¶¦}
|secseparators	    = ¶¦,,¶¦class="dpl dark-background"¦,
}}


Result:

Event Type

Butterfly Dragon

1,980 Gems Icon.png

Frankie Dragon

1,820 Gems Icon.png

Stache Dragon

4,000 Gems Icon.png

Pumpkin Dragon

1,666 Gems Icon.png

Submarine Dragon

1,080 Gems Icon.png

Treater Dragon

1,875 Gems Icon.png

Gobbler Dragon

1,600 Gems Icon.png

Mech Dragon

1,150 Gems Icon.png

Mystic Dragon

962 Gems Icon.png

Elixir Dragon

1,555 Gems Icon.png

Calavera Dragon

1,611 Gems Icon.png

Tiki Dragon

1,615 Gems Icon.png

Midnight Dragon

1,808 Gems Icon.png

Quadwing Dragon

1,814 Gems Icon.png

Jingle Dragon

1,695 Gems Icon.png

Pilgrim Dragon

1,200 Gems Icon.png

Digital Dragon

1,010 Gems Icon.png

Guardian Dragon

30 Dragon Pieces Icon.png

Gem Dragon

1,888 Gems Icon.png

Helper Dragon

995 Gems Icon.png


Code:

<dpl>
  category=Standard Dragons
  notcategory=Clan Dragons
  notcategory=Boss Dragons
  count=20
  includepage={DragonBox}.dragoncostcomparison
  allowcachedresults = true
  mode		    = userformat
  listseparators    = ¶{|class="wikitable sortable" ¶|-¶!Event ¶!Type ,¶|-,¶|-¶|-,¶|}
  secseparators	    = ¶|,,¶|class="dpl dark-background"|,
</dpl>


Result:

Event Type

Butterfly Dragon

1,980 Gems Icon.png

Frankie Dragon

1,820 Gems Icon.png

Stache Dragon

4,000 Gems Icon.png

Pumpkin Dragon

1,666 Gems Icon.png

Submarine Dragon

1,080 Gems Icon.png

Treater Dragon

1,875 Gems Icon.png

Gobbler Dragon

1,600 Gems Icon.png

Mech Dragon

1,150 Gems Icon.png

Mystic Dragon

962 Gems Icon.png

Elixir Dragon

1,555 Gems Icon.png

Calavera Dragon

1,611 Gems Icon.png

Tiki Dragon

1,615 Gems Icon.png

Midnight Dragon

1,808 Gems Icon.png

Quadwing Dragon

1,814 Gems Icon.png

Jingle Dragon

1,695 Gems Icon.png

Pilgrim Dragon

1,200 Gems Icon.png

Digital Dragon

1,010 Gems Icon.png

Guardian Dragon

30 Dragon Pieces Icon.png

Gem Dragon

1,888 Gems Icon.png

Helper Dragon

995 Gems Icon.png