Difference between revisions of "DPL Example 023"

From FollowTheScore
Jump to: navigation, search
(New page: {{Example|Create a SORTED table of articles based on template parameters}} This is basically the same as DPL Example 001. DPL goes through all pages and initially builds an alphabet...)
 
 
(7 intermediate revisions by the same user not shown)
Line 4: Line 4:
  
 
DPL goes through all pages and initially builds an alphabetically sorted list of matching articles.
 
DPL goes through all pages and initially builds an alphabetically sorted list of matching articles.
We output the columns in different order (just for convenience) and thgen we use a small piece of javascript code to resort the table by column one.
+
For convenience we output the columns in different sequence. Therefore we need an phantom template [[Template:Country.listByCapital]] to format the output of each line.
 +
Finally we call a template to resort the table #1 by column #1 immediately before it is being displayed.
 +
 
 +
Had we kept the standard column arrangement from Example 001 we could have done without the phantom template. In this case we would have had to sort table #1 by column #2.
 +
 
 +
If you copy this code to your wiki and you see the sort arrows in the column headings '''appear twice''' you must apply a small patch to the mediawiki sorting script. For details see [[DPL:Manual - DPL parameters: Controlling output order]].
  
 
<pre><nowiki>
 
<pre><nowiki>
 
{{#dpl:
 
{{#dpl:
 
  |category=Fictitious country
 
  |category=Fictitious country
  |include={Country}:capital:name
+
  |include={Country}.listByCapital
  |table=,,Capital,Name
+
  |table=class="wikitable sortable",-,Capital,Country,Official Name
 
}}
 
}}
 
</nowiki></pre>
 
</nowiki></pre>
Line 20: Line 25:
 
{{#dpl:
 
{{#dpl:
 
  |category=Fictitious country
 
  |category=Fictitious country
  |include={Country}:capital:name
+
  |include={Country}.listByCapital
  |table=class=sortable wikitable,-,Capital,[[%PAGE%|%TITLE%]],Official Name
+
  |table=class="wikitable sortable",-,Capital,Country,Official Name
 
}}
 
}}

Latest revision as of 20:48, 22 August 2012

back to list of examples

Create a SORTED table of articles based on template parameters

This is basically the same as DPL Example 001.

DPL goes through all pages and initially builds an alphabetically sorted list of matching articles. For convenience we output the columns in different sequence. Therefore we need an phantom template Template:Country.listByCapital to format the output of each line. Finally we call a template to resort the table #1 by column #1 immediately before it is being displayed.

Had we kept the standard column arrangement from Example 001 we could have done without the phantom template. In this case we would have had to sort table #1 by column #2.

If you copy this code to your wiki and you see the sort arrows in the column headings appear twice you must apply a small patch to the mediawiki sorting script. For details see DPL:Manual - DPL parameters: Controlling output order.

{{#dpl:
 |category=Fictitious country
 |include={Country}.listByCapital
 |table=class="wikitable sortable",-,Capital,Country,Official Name
}}

The above DPL command produces the following output:


Capital Country Official Name
DPL Example 007 main page 1
Bamitogoo Nigunda Republic of Nigunda
Bamitogoo Test Nigunda Test Republic of Nigunda Test
Aaaabququque Somango Somango Island