Example 1

From FollowTheScore
Revision as of 08:33, 5 February 2007 by Gero (talk | contribs)
Jump to: navigation, search

Our demo web site contains some articles on fictitious countries (this is also the name of their common category).

They all use a template named "Country" which has parameters like capital. The template produces a small table and a link to the country list we want to generate. There are chapters on religion and history in most of the articles. We show how to create a sortable wikitable list of those articles which gives some excerpts of the contents. <javascript src="sorttable"/>

DPL can be used as a mediawiki parser extension, which means that a special DPL tag is used:

parser extension syntax

<DPL>
  category=Fictitious country
  includepage={Country} dpl,#History,#Religion[20]
  addpagecounter=true
  mode=userformat
  listseparators=¶{|class=sortablewikitable id=123 ¶!Country ¶!Official Name ¶!Capital ¶!Dial Code ¶!History ¶!Religion ¶|-,¶|-¶|[[%PAGE%]] (%COUNT%)¶,¶,¶|}
  secseparators=,¶|,,
</DPL>

We select articles by category ("Fictitious Country") and explain that we want to see contents from the template "Country" and from two chapters. We truncate the text on religion to a maximum of 10 characters. We create a sortable table which contains the article name (as a link) and its access frequency in the first column and the content pieces in the other columns. Note that at the end of truncated contents you will find a small arrow which links directly to the chapter from where the contents was taken. The formatting for the template variables is done in a special template which is by convention named after the original tenmplate plus a suffix (Template:Country dpl in our case). This template is very simple; it only presents the values for name, capital and dial code as columns of a table.

country list
Country Official Name Capital Dial Code History Religion
DPL Example 007 main page 1 (%COUNT%)

Template:Country dpl.default

Nigunda (%COUNT%) Republic of Nigunda Bamitogoo 237

some facts about ..→

Nigunda Test (%COUNT%) Republic of Nigunda Test Bamitogoo Test 237

Nigunda Test History - Chapter Sequence in the article doesn´t matter for DPL ..

some facts about ..→

Somango (%COUNT%) Somango Island Aaaabququque 224

a text on the history of Somango; a text on the history of Somango; a text on the history of Somango;

some facts about ..→

country list (2)

DPL can also be used as a mediawiki parser function, which is more powerful as it allows DPL to be used within templates, parameters being template calls or variable expansions. The disadvantage is that syntax looks less nice as the pipe character must be hidden in macros if used as a parameter contents. So the same example could also have been written as:

parser function syntax

{{#dpl:category=Fictitious country
  |includepage={Country} dpl,#History[80 img=pointing.hand.gif],#Religion
  |addpagecounter=true
  |mode=userformat
  |listseparators=\n{{(!}} class=sortablewikitable id=123
    \n!Country
    \n!Official Name
    \n!Capital
    \n!Dial Code
    \n!History
    \n!Religion
    \n{{!}}-,\n{{!-}}\n{{!}}[[%PAGE%]] (%COUNT%)\n,\n,\n{{!)}}
  |secseparators=,\n{{!}},,
}}

The result:


Country Official Name Capital Dial Code History Religion
DPL Example 007 main page 1 (%COUNT%)

Template:Country dpl.default

Nigunda (%COUNT%) Republic of Nigunda Bamitogoo 237

some facts about religious groups in Nigunda; some other facts about religious groups in Nigunda;

Nigunda Test (%COUNT%) Republic of Nigunda Test Bamitogoo Test 237

Nigunda Test History - Chapter Sequence in the article doesn´t matter for <linkedimage>page=Nigunda Test#History img=Image:pointing.hand.gif </linkedimage> some facts about religious groups in Nigunda; some other facts about religious groups in Nigunda Test;

Somango (%COUNT%) Somango Island Aaaabququque 224

a text on the history of Somango; a text on the history of Somango; a text on <linkedimage>page=Somango#History img=Image:pointing.hand.gif </linkedimage> some facts about religion in Somango



Have a look at a more realistic example ...