Difference between revisions of "DPL Example 023"

From FollowTheScore
Jump to: navigation, search
 
Line 15: Line 15:
 
  |category=Fictitious country
 
  |category=Fictitious country
 
  |include={Country}.listByCapital
 
  |include={Country}.listByCapital
  |table=class=sortable wikitable,-,Capital,Country,Official Name
+
  |table=class="wikitable sortable",-,Capital,Country,Official Name
 
}}
 
}}
<javascript src="sortTable1byColumn1.js" />
 
 
</nowiki></pre>
 
</nowiki></pre>
  
Line 27: Line 26:
 
  |category=Fictitious country
 
  |category=Fictitious country
 
  |include={Country}.listByCapital
 
  |include={Country}.listByCapital
  |table=class=sortable wikitable,-,Capital,Country,Official Name
+
  |table=class="wikitable sortable",-,Capital,Country,Official Name
 
}}
 
}}
<javascript src="sortTable1byColumn1.js" />
 

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